Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 02-03-2005, 05:15 PM   #1
Member (7 bit)
 
Join Date: Nov 2003
Posts: 76
Exclamation Java Program help please

Ok Im suppose to write a "simple program" or my csci class showing flight departure and arrival time. I have typed in a few lines of code that my instructor showed us in class but Im still completely lost. It is suppose to look like one of these examples here.
Java Program
Ive already done steps 1-3 its just step 4 the actual excercise Im having problems with.

can someone please help?
rr spyda is offline   Reply With Quote
Old 02-03-2005, 05:45 PM   #2
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
Are you having problems with the calculations or the print statements?
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
Force Flow is offline   Reply With Quote
Old 02-03-2005, 05:47 PM   #3
Member (7 bit)
 
Join Date: Nov 2003
Posts: 76
both. this is what I have in notepad so far but I think most of it is wrong.
Code:
import TerminalIO.KeyboardReader;

 public class cag02 {
	public static void main (String [] args) {
	 Int beginHr
	 Int beginMin
	 Int endMin
	 Int totalMins

	System.out.print ("Please provide four inputs about your flight: ") ;
	fahrenheit = reader.readDouble () ;

	System.out.print ("Enter departure hour: ") ;
	beginltr=rdri readInt () ;

	System.out.print ("Enter departure minute: ") ;
	beginltr=rdri readInt () ;

	System.out.print ("Enter arrival hour: ") ;
	beginltr=rdri readInt () ;

	System.out.print ("Enter arrival minute: ") ;
	beginltr=rdri readInt () ;
	reader.pause ();
    }
  }
rr spyda is offline   Reply With Quote
Old 02-03-2005, 06:09 PM   #4
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
First off, you need to end all your variable initilization statements with a semicolan just like any other statement.

I'm not sure what your rdri statement is for. I haven't run across that before.

There's something wrong with the import statement as well. Take a look here: http://www.javakb.com/Uwe/Forum.aspx...Compile-issues
Force Flow is offline   Reply With Quote
Old 02-03-2005, 06:31 PM   #5
Member (7 bit)
 
Join Date: Nov 2003
Posts: 76
Revision*
Code:
public class cag02 { 
   public static void main (String [] args) { 
KeyBoardReader reader = new KeyBoardReader(); 
    int beginHr; 
    int beginMin; 
int endHr; 
    int endMin; 
    int totalMins; 

   System.out.println ("Please provide four inputs about your flight: ") ; 
    

   System.out.println ("Enter departure hour: ") ; 
   beginHr=reader.readInt() ; 

   System.out.println ("Enter departure minute: ") ; 
   beginMin=reader.readInt() ; 

   ln("Enter arrival hour: ") ; 
   endHr=reader.readInt() ; 

   System.out.println ("Enter arrival minute: ") ; 
   endHr=reader.readInt() ; 
   reader.pause (); 
    } 
  }

Last edited by rr spyda; 02-03-2005 at 06:36 PM.
rr spyda is offline   Reply With Quote
Old 02-03-2005, 06:36 PM   #6
Member (9 bit)
 
colecifer's Avatar
 
Join Date: Jan 2004
Location: Kansas City(westwood), KS
Posts: 458
I am unfamiliar with keyboard reader, i've only used buffer reader for text input. I know that with the buffere reader method you must add throws IO exception(i am not sure if i have the case right for that) after the public class statement. I am unsure if the Keyboard reader package needs this. Could you please tell us what kind of errors you get from your compiler? That should help us a little.
colecifer is offline   Reply With Quote
Old 02-03-2005, 07:22 PM   #7
Member (7 bit)
 
Join Date: Nov 2003
Posts: 76
*Revision
Code:
import TerminalIO.KeyboardReader;

public class cag02 { 
   public static void main (String [] args) { 

    int beginHr; 
    int beginMin; 
    int endHr; 
    int endMin; 
    int totalMins; 
 
   System.out.println ("Please provide four inputs about your flight: ") ; 
    
 
   System.out.println ("Enter departure hour: ") ; 
   beginHr=reader.readInt() ; 
 
   System.out.println ("Enter departure minute: ") ; 
   beginMin=reader.readInt() ; 
 
   System.out.println ("Enter arrival hour: ") ; 
   endHr=reader.readInt() ; 
 
   System.out.println ("Enter arrival minute: ") ; 
   endMin=reader.readInt() ; 
   
 
   System.out.println ("Your flight departs at: "+beginHr+":"+beginMin);
   System.out.println ("Your flight arrives at: "+endHr+":"+endMin);
   totalMins=endMin +beginMin;
   System.out.println("flight time: "+totalMins);
   }
}

Last edited by rr spyda; 02-03-2005 at 10:29 PM.
rr spyda is offline   Reply With Quote
Old 02-03-2005, 11:30 PM   #8
Member (7 bit)
 
Join Date: Nov 2003
Posts: 76
I got my program working, can someone just help me with the flight calculations now?
rr spyda is offline   Reply With Quote
Old 02-07-2005, 10:27 PM   #9
Lest we forget
 
ghost2003's Avatar
 
Join Date: Jun 2003
Location: Ontario, Canada
Posts: 1,870
you are just calculating the minutes, you also need the hours. Try this
Code:
totalMins=endMin -beginMin+(60*(endHr-beginHr));
__________________
redqueen: Antec Sonata, Pentium-D 2.5GHz, MSI G31M3-L, 2GB ram, 320 GB HDD, OpenBSD
hal9000: Lenovo T61, 2GB ram, 120 GB HDD, FreeBSD
ghost2003 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:17 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2