import javax.swing.JOptionPane;
public class AgeCalculator
{
public static void main(String[] args)
{
String name;
name = JOptionPane.ShowInputDialog( "Please type in your name." );
String thisYearString;
thisYearString = JOptionPane.ShowInputDialog( "Please type in what year this is. Use Numbers." );
int thisYear;
thisYear = Integer.parseInt( thisYearString );
String birthYearString;
birthYearString = JOptionPane.ShowInputDialog( "Please type in what year you were born. Use numbers." );
int birthYear;
birthYear = Integer.parseInt( birthYearString );
int age;
age = thisYear - birthYear;
String print;
print = "Hi " + name + " , this year you will be " + age + " years old." + "\n";
// print = print + "You are still young, wild and free! #YOLO";
JOptionPane.showMessageDialog(null, print);
// Hvorfor fungerer ikke dette? "Results", JOptionPane.PLAIN_MESSAGE);
}
}
Registrerte brukere: Google [Bot]