Program doesn't continue...
I am using NetBeans 6.1, and our book is Introduction to Java Programming by Y. Daniel Liang.
This is an agechecking program.
Here is my code, it appears error free, but when run it doesn't print to the console - seemingly ignoring getInfo in main....
Code:
package agecheck;
/**
*
* @author 06111246
*/
import javax.swing.*;
import java.util.*;
public class AgeCheck {
private
String Name;
String Age;
int iAge;
Scanner scanner = new Scanner(System.in);
boolean continueInput = true;
void setInfo()
{
Name = JOptionPane.showInputDialog(" Please enter your name:");
Age = JOptionPane.showInputDialog("Enter your age: ");
iAge = Integer.parseInt(Age);
//int number = iAge;
do
{
try{
int number = scanner.nextInt();
JOptionPane.showMessageDialog(null, "You entered " + iAge);
continueInput = false;
}
catch (InputMismatchException number)
{
JOptionPane.showMessageDialog(null, "Enter a number for your age");
scanner.nextLine();
}
}while (continueInput);
}
int getInfo(int Check)
{
System.out.println
(Name + ", you are " + iAge + " years old.");
if (iAge > 16)
System.out.println("You are old enough to drive");
else
System.out.println("You are not old enough to drive");
if (iAge > 18)
System.out.println("You are old enough to vote");
else
System.out.println("You are not old enough to vote");
if (iAge >21)
System.out.println("You are old enough to drink");
else
System.out.println("You are not old enough to drink");
if (iAge > 72)
System.out.println("You are old enough to be put out to pasture");
else
System.out.println("You are not old enough to retire");
return 0;
}
}
HERE IS MY MAIN:
package agecheck;
/**
*
* @author 06111246
*/
public class Main
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
int Check = 0;
AgeCheck oAgeCheck;
oAgeCheck = new AgeCheck();
oAgeCheck.setInfo();
oAgeCheck.getInfo(Check);
}
}
Again, i get no errors, I am wondering why it won't complete the program to tell if the age entered allows driving, voting, etc..
thanks
Reiyn