Results 1 to 12 of 12
  1. #1
    XSkyline is offline Member
    Join Date
    Nov 2014
    Posts
    8
    Rep Power
    0

    Default Help | Parking program

    Hello
    i'm learning for the first time
    and i need to crate a Parking program

    Java Code:
    import java.util.*;
     class xxx
     {
        public static void Parking (String args[])
        {
            
            Scanner snip = new Scanner (System.in);
            System.out.println("Enter time:");
            int Enter_time1;
            int Enter_time2;
            Enter_time1= snip.nextInt();
            Enter_time2= snip.nextInt();
            
            System.out.println("Enter exit time:");
            
            int exit_time1;
            exit_time1= snip.nextInt(); 
            int exit_time2;
            exit_time1 = snip.nextInt();
    
            
            int totalH = exit_time1*60 + exit_time2 - Enter_time1*60 + Enter_time2;
       
        }
    }
    the first hour is free
    and after the first hour every minute you'll need to pay.

    the second hour is 3 dollars
    that means that if your car was Parikng 120 minutes you'll pay only 3 dollars

    for the third hour you'll pay 1 dollar every 15 minutes

    after 18:00 o'clock you'll pay only one time 10 dollars now matter for how long you'll be parking

    it need to look like this:

    Enter entrance time:
    20 15
    Enter exit time:
    21 30
    Total charge is 20 $.
    Enter entrance time:
    10 40
    Enter exit time:
    10 55
    No charge.
    Enter entrance time:
    7 30
    Enter exit time:
    9 00
    Total charge is 10 $.
    Enter entrance time:
    13 00
    Enter exit time:
    18 20
    Total charge is 52 $.
    and if the user is using too much numbers it need to says ".".Error! Illegal data"
    Last edited by XSkyline; 11-08-2014 at 10:58 AM.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: Help | Parking program

    You forgot to ask a question.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    XSkyline is offline Member
    Join Date
    Nov 2014
    Posts
    8
    Rep Power
    0

    Default Re: Help | Parking program

    how to continue it ? >:

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Help | Parking program

    how to continue it?
    Make a list of the steps the program needs to do to solve the problem.
    Then start at the first step in the list: code it, compile it, test it. When its working, move to next item.

    If you have problems, post the code, the full text of any error messages and your questions.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    XSkyline is offline Member
    Join Date
    Nov 2014
    Posts
    8
    Rep Power
    0

    Default Re: Help | Parking program

    i don't know the steps >:

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Help | Parking program

    If you do not know what the program is supposed to do, that makes it almost impossible to write it.

    Take some time to think about what the program is supposed to do. There are items in the first post that list what it is supposed to do. Pick one and work out how you would solve it manually. What are the steps you'd take using paper and pencil to solve it.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    XSkyline is offline Member
    Join Date
    Nov 2014
    Posts
    8
    Rep Power
    0

    Default Re: Help | Parking program

    my first step it how to do
    free first hour

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Help | Parking program

    How would you do it manually? Given the time that a car was parked, what would you do to compute the charges?
    Say a car was parked for 2 hours, what are the steps to compute the charges?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    XSkyline is offline Member
    Join Date
    Nov 2014
    Posts
    8
    Rep Power
    0

    Default Re: Help | Parking program

    i did it but why is not work >:

    Java Code:
    import java.util.*;
     class Parking
     {
        public static void Parking (String args[])
        {
            
            Scanner snip = new Scanner (System.in);
            System.out.println("Enter entrance time:");
            int timeHours;
            int timeMin;
            timeHours = snip.nextInt();
            timeMin = snip.nextInt();
            System.out.println("Enter exit time:");
            
            int timeHours1;
            timeHours1 = snip.nextInt(); 
            int timeMin1;
            timeMin1 = snip.nextInt();
            int enterTotalHours;
            int exitTotslHours;
            int total;
            int totalX;
            
            
            enterTotalHours = timeHours*60+timeMin;
            exitTotslHours = timeHours1*60+timeMin1;
            total = exitTotslHours - enterTotalHours;
             
                 if (total<120){
                }
                if (total<120){
                }  
                if (total> 60){
                }  
            
            totalX = total - 120;
            while(timeMin>0){
                int count;
                timeMin1-= total;
        }  
        
        System.out.println ("Total charge is "+timeMin1+" $");
            
       
        }
    }
    help plz
    Last edited by XSkyline; 11-08-2014 at 07:00 PM.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Help | Parking program

    why is not work
    Please explain. Copy the program's output and paste it here. Add some comments describing what is wrong and show what the output should be.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    XSkyline is offline Member
    Join Date
    Nov 2014
    Posts
    8
    Rep Power
    0

    Default Re: Help | Parking program

    output should be
    Enter entrance time:
    20 15
    Enter exit time:
    21 30
    Total charge is 20 $.

    and i get
    Enter entrance time:
    20 15
    Enter exit time:
    21 30
    Total charge is 75 $
    =\

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Help | Parking program

    Looks like the math is wrong if the program computes 75 when it should be 20.
    Please write down all the steps you take manually to get the value 20.


    To see where the code in the program is going wrong, add a println() statement after each statement that does a computation that prints out the results of that statement. The print out will show you which statement is going wrong.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. help with program that calculates parking fee
    By d2idan in forum New To Java
    Replies: 3
    Last Post: 10-23-2014, 05:46 PM
  2. parking code
    By disel in forum New To Java
    Replies: 26
    Last Post: 05-17-2014, 09:47 AM
  3. Parking Ticket Simulator
    By Anthony5347 in forum New To Java
    Replies: 0
    Last Post: 12-07-2013, 06:10 AM
  4. a parking garage program
    By jihad in forum New To Java
    Replies: 3
    Last Post: 12-24-2011, 02:06 PM

Posting Permissions

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