Help how to simplify this problem code.

Is there a way to edit the code to enable that i don have so many if statements..
what can do to improve pls help.
my code is:
public class tradeFair1 {
     public static void main(String[]arguments){
          double studentM=1.00, studentA=1.20, studentE=3.50;
          double SnrCitizenM=1.20,SnrCitizenA=1.50, SnrCitizenE=3.50;
          double GenPubM=2.00, GenPubA=2.50, GenPubE=3.50;
          boolean weekDays = false;
          double price, status;
     int day = Console.readInt("Enter 1 for Monday, 2 for Tuesday.....6 for Saturday, 7 for Sunday: ");
     int buyer = Console.readInt("Enter 1 for Student, 2 for SnrCitizen, and 3 for GeneralPublic: ");
int timeOfDay = Console.readInt("Enter the timeOfDay 1 for Morning, 2 for afternoon, 3 for evening: ");
          int numOfTickets = Console.readInt("Enter the number of Tickets");
               if (day >= 1 && day <= 5) {
                    weekDays = true;
                    if (buyer==1 && timeOfDay==1) {
                         status = studentM;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price -(price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==1 && timeOfDay==2) {
                         status = studentA;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==1 && timeOfDay==3) {
                         status = studentE;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==2 && timeOfDay==1) {
                         status = SnrCitizenM;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==2 && timeOfDay==2) {
                         status = SnrCitizenA;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==2 && timeOfDay==3) {
                         status = SnrCitizenE;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==3 && timeOfDay==1) {
                         status = GenPubM;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==3 && timeOfDay==2) {
                         status = GenPubA;
                         price = numOfTickets*status;;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (buyer==3 && timeOfDay==3) {
                         status = GenPubE;
                         price = numOfTickets*status;
                         if (numOfTickets >=10 && numOfTickets <=15)
                              price = price - (price*0.1);
                              if (numOfTickets >15)
                              price = price - (price*0.15);
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
               else if (weekDays = false) {
                    if (timeOfDay ==1) {
                         status = GenPubM;
                         price = numOfTickets*status+0.50;
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (timeOfDay ==2) {
                         status = GenPubA;
                         price = numOfTickets*status+0.50;
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);
                    if (timeOfDay ==3) {
                         status = GenPubE;
                         price = numOfTickets*status+0.50;
                         price = price + (price*0.05);
                         System.out.println("The price is: $" +price);

this is total aircode - just to give you an idea
class TradeFair1
  double[][] prices = {{1.00,1.20,3.50},{1.20,1.50,3.50},{2.00,2.50,3.50}};
  double cost = 0;
  public TradeFair1()
    int buyer = Console.readInt("Enter 1 for Student, 2 for SnrCitizen, and 3 for GeneralPublic: ") - 1;
    int timeOfDay = Console.readInt("Enter the timeOfDay 1 for Morning, 2 for afternoon, 3 for evening: ") - 1;;
    int numOfTickets = Console.readInt("Enter the number of Tickets");
    int day = Console.readInt("Enter 1 for Monday, 2 for Tuesday.....6 for Saturday, 7 for Sunday: ");
    double disc;
    if(numOfTickets < 10) disc = 1.00;
    else if(numOfTickets < 16) disc = 0.90;
    else disc = 0.85;
    if(day < 6) cost = numOfTickets * prices[buyer][timeOfDay] * disc;
    else cost = numOfTickets * prices[2][timeOfDay] + 0.50;
  public static void main(String[]arguments){new TradeFair1();}
}

Similar Messages

Maybe you are looking for

  • Why iPhoto 9.4 get crash with the latest OSX 10.8.2 ?can you help

    can't understand why this happen as soon as i updeate my iphoto to 9.4 the program screen start to run from one desktop to other !!!! can't even rename the faces and the program start to do the same ... is this problem due to the prgrams of to other

  • Cannot install apps on my bb

    I cannot install several apps on my bb 9360 (Vodafone Ro) - qik, shazam, eagleeye, etc. For all of these i get the error message The Item is not available for your Device Model, Device OS, Carrier and Country combination. Pls advise.

  • How to enable soa gateway in oracle apps r12?

    how to enable soa gateway in oracle apps r12?

  • How can I load images without XML, please?

    Hello Everyone, I would highly appreciate it if someone can point me into the right direction. I have some AS2 code which loads up the images via an xml file. I have been asked to eliminate XML entirely and have images be loaded from with in the libr

  • Load Balancing in EJB ???

    Hi everyone Can anyone guide me how can I achieve failover/IIOP load balancing in EJB. Thanks, AA