import java.util.*;

class Salon
{
    static Scanner sc = new Scanner(System.in);
   
    public static void main (String[] args)
    {
      int skinType,option,maskType,massageType;
     
     
      System.out.println ("\t\t*********************");
      System.out.println ("\r Welcome to Sally Salon");
      System.out.println ("\r Services available:");
      System.out.println ("\r 1.facial and massage");
      System.out.println ("\r 2.facial only");
      System.out.println ("\r 3.massage only");
      System.out.println ("\t\t*********************");
      System.out.println ("\t Enter your option:");
      option=sc.nextInt();
     
     
      System.out.println ("\n\t\t********************");
      System.out.println ("\r Skin type");
      System.out.println ("\r 1.normal");
      System.out.println ("\r 2.combination");
      System.out.println ("\r 3.problematic");
      System.out.println ("\n\t\t*********************");
      System.out.println ("\r Enter your skin type:");
      skinType=sc.nextInt();
      
     
      System.out.println ("\r mask type:");
      System.out.println (" 1.Hot");
      System.out.println (" 2.cold");
      maskType=sc.nextInt();
      
      
      System.out.println ("\r massageType:");
      System.out.println ("\r 1.)Foot reflexology");
      System.out.println ("\r 2.)Traditional");
      System.out.println ("\r 3.)Aromatherapy");
      System.out.println ("\r 4.)After birth");
      massageType=sc.nextInt();
      
     
      {
      if (skinType==1&&maskType==1)
      {System.out.println ("\r Your bill");
      System.out.println ("\r Charge for normal skin, mask type hot RM45.00");
      }
      else
      if (skinType==1&&maskType==2)
      {System.out.println ("\r Your bill");
      System.out.println ("\r Charge for normal skin, mask type cold RM50.00");
      }
      else
      if (skinType==2&&maskType==1)
      {System.out.println ("\r Your bill");
      System.out.println ("\r Charge for combination skin, mask type hot RM50.00");
      }
      else
      if (skinType==2&&maskType==2)
      {System.out.println ("\r Your bill");
      System.out.println ("\r Charge for combination skin, mask type cold RM55.00");
      }
      else
      if (skinType==3&&maskType==1)
      {System.out.println ("\r Your bill");
      System.out.println ("\r Charge for problematic skin, mask type hot RM60.00");
      }
      else
      if (skinType==3&&maskType==2)
      {System.out.println ("\r Your bill");
      System.out.println ("\r Charge for problematic skin, mask type cold RM65.00");
      }
      else
      System.out.println ("\t\t********************");}
     
}
}

this program is incomplete,i just want to ask :
how to write the command for the program when i choose option 3,it supposed to generate only massageType and not skinType and if i type other number like 5 it suppose to generate error!!!

mvmalderen commented: We don't give a toss about your urgency. -4

Recommended Answers

All 4 Replies

surround the massage type and the skin type with the if statement depending on your requirement so that it would only ask if certain option is selected

This is obviously a homework assignment so I don't want to just hand you the answer, but I will make a suggestion and offer an explanation.

You'll want to take each block of code that performs a discrete task and make it a method. For example, put the code that selects from the 3 services available and put it in a method called selectService which returns an int.

Then in your main method call the first method, and perform some logic based on the return value of the method call and decide which of the other methods to call either in a switch or through a series of if statements.

If you wanted to allow the app to run continuously, you could wrap the while thing in a while loop checking to see if the user selected an exit option (which you'd have to add to your other methods).

Regards,

Tim

thanks for helping.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.