Thread: java help
View Single Post
 
java help
Reply
Posted 2009-05-11, 07:22 AM
ok i have java question i had to do this for class but it doesnt work.
they program ask user for their age and tell them if they can drink, drive or retire here what i have so far tell me what i am doing wrong.

import javax.swing.JOptionPane;
import java.util.Scanner;

public class Main {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);


//String name;


//name = JOptionPane.showInputDialog("what is your name");
//int names = Integer.parseInt(name);

String age = JOptionPane.showInputDialog("what is your age");
int ages = Integer.parseInt (age);

if (ages < 18){

System.out.println("you are too young to drive");
System.out.println(" you are too young to drink");
System.out.println("you are too young to retire");

}else if (ages >= 21){

System .out.println("you can drive");
System.out.println("you can go to bar and drink");
System.out.println("you can't retire yet");

}else if (ages >= 65){
System.out.println("you can drive");
System.out.println("you can drink");
System.out.println("you can retire now");

}
}
}
Old
Profile PM WWW Search
osmoses-jones is neither ape nor machine; has so far settled for the in-betweenosmoses-jones is neither ape nor machine; has so far settled for the in-between
 
osmoses-jones