Re: Summer Project - Stuck?
Quote:
Originally Posted by
hillzyy
...
---------------------------------------------------------------
I have tried and got this so far,
---------------------------------------------------------------
Code :
import java.util.Scanner; //package needed to read from keyboard
public class Exercise2
{
public static void main (String[] args)
{
//declare Scanner and integer variables
Scanner scan = new Scanner (System.in);
int allMonths, years, partMonths;
//ask for age in months
String inData;
System.out.println("Age in months: ");
inData = scan.nextLine();
//set allMonths to value typed in
//calculate years from allMonths
//code here
//calculate partMonths from allMonths
//code here
//display message about calculated years and months
//code here
}//end main
}//end class
...
Well what does the program do so far?
Does it compile?
Does it run?
Do you have any error messages?
If you were to run it in the debugger, and add a breakpoint after:
inData = scan.nextLine();
... does inData hold the String you expect to see there?
What is broken? Where are you stuck?
...Short of doing the entire work for you, you leave not much clue what it is you need help with.
Re: Summer Project - Stuck?
@Krumpir, please read the forum rules and the following:
http://www.javaprogrammingforums.com...n-feeding.html