Results 1 to 2 of 2
  1. #1
    herberwz is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Default Java application to calculate and display the cost of a number of tickets according

    Java application to calculate and display the cost of a number of tickets according to the rules:
    7 per ticket for children (age < 18)
    10 per ticket for adults (age between 18 and 59)
    8 per ticket for senior citizens (age > 59)
    The customer enters two whole numbers age and tickets (the number of tickets required) on the command line and the program should calculate and display the cost of that number of tickets for the customer.





    XML Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class Tickets {
        public static void main(String[] args) {
            int age = Integer.parseInt(args[0]);
            int tickets = Integer.parseInt(args[1]);
            
    		int cost = 7;
    
    		if (age < 18)
    		{
    			cost = 8;
    		} else if (age > 59)
    
    		{
    			cost = 10 ;
    		} else if (age < 59)
    
    	
    		{
    			cost = 10;
    		}
    		
    		System.out.println("The tickets is " + (tickets*cost) + " pounds");
        }
    }
    I knt cn to get the right answer please help

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by herberwz View Post
    I knt cn to get the right answer please help
    Please translate this into standard English if you want to maximize your chances of getting help. Also, what and how is your code not working? If you are getting any error messages, please post them. The more you can tell us, the easier it will be to help. Best of luck.

Similar Threads

  1. Replies: 12
    Last Post: 04-16-2010, 02:18 PM
  2. Trying to calculate cost based on size
    By space4rent00 in forum New To Java
    Replies: 4
    Last Post: 03-22-2010, 07:13 AM
  3. Check difference between no. of stops, calculate cost
    By JavaStudent23 in forum New To Java
    Replies: 1
    Last Post: 11-14-2009, 04:03 PM
  4. Need help with calculate the number of seconds
    By ProUnbeatable in forum New To Java
    Replies: 5
    Last Post: 10-11-2008, 03:07 AM
  5. Replies: 0
    Last Post: 03-25-2008, 12:45 AM

Posting Permissions

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