Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple program help

    Hi guys im new to Java and just need a bit of help with a program i am making

    What i have is a program that lets the user enter 2 numbers the first number being there age and the second number is the amount of tickets required ,
    i have 2 age groups so far one for ages less than 18 and one for ages greater than 59 i need a 3rd age group for ages between 18 and 59 and this is where im getting stuck, here is my code below .


    class numbaz
    {
    public static void main(String[] args)
    {
    int a,b,c,d,e;
    a= Integer.parseInt(args[0]) ;
    b= Integer.parseInt(args[1]);
    c= 18;
    d= 10;

    if (a<18)



    System.out.println("The cost is " + d*b + "pounds");


    else if (a>59)

    System.out.println("The cost is " + c*b+ " pounds");
    }

    }

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Code:
    if(a<18)
          // first block
    elseif(a>18 && a<59)
        //second
    elseif(a>59)
          //third
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •