Results 1 to 10 of 10
  1. #1
    adamrain is offline Member
    Join Date
    Nov 2009
    Posts
    19
    Rep Power
    0

    Default student need help

    im onley starting to learn jave and i have assignmentim im having troble whith.

    it goes like this i gotta create a class calld flight, its an input (scanner) program for airplane landing time ...

    the input is:
    2 4
    9 22

    the output is:
    The arrival time is: hour - 2, minute - 4
    Time of flight is: hour - 9, minute - 22
    The departure time is: hour - 16, minute - 42

    this is what i wrote in bluej and the compiler is giving me hard time:

    import scanner.utils;
    public class Flight
    {
    public static void main (String[ ] args) {

    int ftime,fland,Fout,m,h,m1,h1;
    Fout=h+י12;


    SimpleInput sinp = new SimpleInput(System.in);
    System.out.println("write The arrival time,hour and minutes ");
    h=sinp.readInt();
    m=sinp. nextInt();
    System.out.println("write Time of flight ");
    h1=sinp.readInt();
    m1=sinp. nextInt();
    sinp. close();

    System.out.println(“The arrival time is ” +h":"+m);
    System.out.println(“Time of flight is:” +h1+":"+m2);
    System.out.println(“The departure time is:” +fout );
    }
    }

  2. #2
    sky
    sky is offline Member
    Join Date
    Nov 2009
    Posts
    96
    Rep Power
    0

    Default

    You forgot a + here:

    Java Code:
    System.out.println(“The arrival time is ” +h":"+m);
    If you post the code with CODE tags I can run it and tell you more.

    You put some strange caracter after 12 you should remove:

    Java Code:
    Fout=h+י12;

  3. #3
    adamrain is offline Member
    Join Date
    Nov 2009
    Posts
    19
    Rep Power
    0

    Default

    its a lost cause,the univrsty told me i have untill the end of this evning.

    i hope somone wll be able to help me next time.

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

    Default

    Quote Originally Posted by adamrain View Post
    its a lost cause,the univrsty told me i have untill the end of this evning.

    i hope somone wll be able to help me next time.
    I hope you start your project earlier (so as not to be in a rush for an answer), provide the error messages, reply to replies given, and use code tags next time. Much luck.
    Last edited by Fubarable; 11-28-2009 at 09:04 PM.

  5. #5
    sky
    sky is offline Member
    Join Date
    Nov 2009
    Posts
    96
    Rep Power
    0

    Default

    That's right, if you post your code as a quote I have to copy it to my IDE and when I run it is not the same one as you are running (the quote enviroment changes some things)

  6. #6
    adamrain is offline Member
    Join Date
    Nov 2009
    Posts
    19
    Rep Power
    0

    Default

    its ok now i handled it but tomrow i have a new one...(oh and if you can help me fix the part that didnt work out ill be happy:
    System.out.println("The departure time is (had no idea how to fix it...):" +Fout )
    ).

    and i figurd out the real problem,im a lazy jerk

    import java.util.Scanner;
    public class Flight
    {
    public static void main (String[ ] args) {

    Scanner sinp = new Scanner(System.in);
    System.out.println("write The arrival time,hour and minutes, with space between them");
    int h=sinp.nextInt();
    int m=sinp. nextInt();
    System.out.println("write Time of flight hour and minutes, with space between them ");
    int h1=sinp.nextInt();
    int m1=sinp. nextInt();
    int Fout=h%12;
    System.out.println("The arrival time is"+h+":"+m);
    System.out.println("Time of flight is:" +h1+":"+m1);
    System.out.println("The departure time is (had no idea how to fix it...):" +Fout );
    sinp. close();



    }
    }
    Last edited by adamrain; 11-28-2009 at 10:01 PM.

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

    Default

    Again, please use code tags when posting code here, not quotes. See my signature below regarding how to use code tags. Again, if you are having any errors, please post the error messages. Also please indicate in your code with a comment which line is tripping the error.

    If it's not an error message but rather your program not working as expected, please let us know what it is currently doing that it's not supposed to be doing and what it's not doing that it's supposed to be doing.

    Much luck!

  8. #8
    adamrain is offline Member
    Join Date
    Nov 2009
    Posts
    19
    Rep Power
    0

    Default

    thank you ill post it in code tag

    Java Code:
    import java.util.Scanner;
    public class Flight
    {
    public static void main (String[ ] args)   {  
      
    Scanner sinp = new Scanner(System.in);
    System.out.println("write The arrival time,hour and minutes, with space between them");
    int h=sinp.nextInt();
    int m=sinp. nextInt();
    System.out.println("write Time of flight hour and minutes, with space between them ");
    int h1=sinp.nextInt();
    int m1=sinp. nextInt();
    //this spose to calculate the time the plane left the last airport
    int Fout=h%12;
    System.out.println("The arrival time is"+h+":"+m);  
        System.out.println("Time of flight is:" +h1+":"+m1);
        //im spose to make the next line show the time the plane left the last airport
        System.out.println("The departure time is (had no idea how to fix it...):" +Fout );
    sinp. close();
      
     
       
             }
    }
    i had no syntex error and mange to run it expt the part of the departure time (i wrote it in the code in commants),but as it is i shold get a good mark.
    Last edited by adamrain; 11-28-2009 at 11:04 PM.

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

    Default

    So what confuses you, the math? It's basically nothing more than subtracting time on the clock. You should be able to figure this out on paper as most of us learned this in grade school. Once you've done this, try to translate what you've done into Java.

    If you've tried to do this, let's see what you've done. Again, show the code.

    Much luck!

  10. #10
    sky
    sky is offline Member
    Join Date
    Nov 2009
    Posts
    96
    Rep Power
    0

    Default

    I agree with Fubarable, but I re-write your code in another style that I think is more readable. Basically, you have to indent your code and give the variables significant names

    Java Code:
    import java.util.Scanner;
    
    public class Flight
    {
        public static void main (String[ ] args)   {  
      
            Scanner sinp = new Scanner(System.in);
            
            System.out.println("Write the arrival time, hour and minutes, with space between them:");
            int arrivalHour = sinp.nextInt();
            int arrivalMin = sinp.nextInt();
            
            System.out.println("Write the time of the flight, hour and minutes, with space between them:");
            int durationHour = sinp.nextInt();
            int durationMin = sinp.nextInt();
            
            int departureHour = 
            int departureMin = 
            
            System.out.println("The arrival time is" + arrivalHour + ":" + arrivalMin);  
            System.out.println("The time of flight is:" + durationHour + ":" + durationMin);
            System.out.println("The departure time is:" + departureHour + ":" + departureMin);
            
            sinp.close();
        }
    }

Similar Threads

  1. New java student needs help
    By cmizer in forum New To Java
    Replies: 9
    Last Post: 12-13-2008, 06:16 AM
  2. Student--begginer--help!!!
    By AmandaIT in forum New To Java
    Replies: 6
    Last Post: 05-09-2008, 03:37 AM
  3. Student Help
    By mattwaab in forum Java Applets
    Replies: 0
    Last Post: 02-08-2008, 05:31 PM
  4. help student
    By jvasilj1 in forum New To Java
    Replies: 15
    Last Post: 02-02-2008, 08:23 AM
  5. please help a student
    By jvasilj1 in forum New To Java
    Replies: 0
    Last Post: 02-01-2008, 01:11 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
  •