Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-28-2009, 05:43 PM
Member
 
Join Date: Nov 2009
Posts: 19
Rep Power: 0
adamrain is on a distinguished road
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:

Quote:
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 );
}
}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-28-2009, 05:49 PM
sky sky is offline
Member
 
Join Date: Nov 2009
Posts: 96
Rep Power: 0
sky is on a distinguished road
Default
You forgot a + here:

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:

Code:
Fout=h+י12;
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-28-2009, 08:53 PM
Member
 
Join Date: Nov 2009
Posts: 19
Rep Power: 0
adamrain is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-28-2009, 09:02 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 8,461
Rep Power: 11
Fubarable is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-28-2009, 09:41 PM
sky sky is offline
Member
 
Join Date: Nov 2009
Posts: 96
Rep Power: 0
sky is on a distinguished road
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)
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-28-2009, 09:57 PM
Member
 
Join Date: Nov 2009
Posts: 19
Rep Power: 0
adamrain is on a distinguished road
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:
Quote:
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

Quote:
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-28-2009, 10:07 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 8,461
Rep Power: 11
Fubarable is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 11-28-2009, 11:00 PM
Member
 
Join Date: Nov 2009
Posts: 19
Rep Power: 0
adamrain is on a distinguished road
Default
thank you ill post it in code tag

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.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 11-28-2009, 11:04 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 8,461
Rep Power: 11
Fubarable is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 11-28-2009, 11:10 PM
sky sky is offline
Member
 
Join Date: Nov 2009
Posts: 96
Rep Power: 0
sky is on a distinguished road
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

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();
    }
}
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New java student needs help cmizer New To Java 9 12-13-2008 06:16 AM
Student--begginer--help!!! AmandaIT New To Java 6 05-09-2008 03:37 AM
Student Help mattwaab Java Applets 0 02-08-2008 05:31 PM
help student jvasilj1 New To Java 15 02-02-2008 08:23 AM
please help a student jvasilj1 New To Java 0 02-01-2008 01:11 AM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 08:28 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org