
11-28-2009, 05:43 PM
|
|
Member
|
|
Join Date: Nov 2009
Posts: 19
Rep Power: 0
|
|
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 );
}
}
|
|
|

11-28-2009, 05:49 PM
|
|
Member
|
|
Join Date: Nov 2009
Posts: 96
Rep Power: 0
|
|
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:
|
|

11-28-2009, 08:53 PM
|
|
Member
|
|
Join Date: Nov 2009
Posts: 19
Rep Power: 0
|
|
|
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.
|
|

11-28-2009, 09:02 PM
|
 |
Moderator
|
|
Join Date: Jun 2008
Posts: 8,461
Rep Power: 11
|
|
Originally Posted by adamrain
|
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.
|
|

11-28-2009, 09:41 PM
|
|
Member
|
|
Join Date: Nov 2009
Posts: 96
Rep Power: 0
|
|
|
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)
|
|

11-28-2009, 09:57 PM
|
|
Member
|
|
Join Date: Nov 2009
Posts: 19
Rep Power: 0
|
|
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.
|
|

11-28-2009, 10:07 PM
|
 |
Moderator
|
|
Join Date: Jun 2008
Posts: 8,461
Rep Power: 11
|
|
|
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!
|
|

11-28-2009, 11:00 PM
|
|
Member
|
|
Join Date: Nov 2009
Posts: 19
Rep Power: 0
|
|
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.
|
|

11-28-2009, 11:04 PM
|
 |
Moderator
|
|
Join Date: Jun 2008
Posts: 8,461
Rep Power: 11
|
|
|
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!
|
|

11-28-2009, 11:10 PM
|
|
Member
|
|
Join Date: Nov 2009
Posts: 96
Rep Power: 0
|
|
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();
}
} |
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 08:28 AM.
|
|