Hello!
I'm really new to Java and i've ran into a problem. I'm making a program that asks you for your age and tells you what you can do at that age. Here is the code:
package switchpkg;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner auto = new Scanner(System.in);
System.out.println("Tell me how old you are and i will tell you what you can do");
int age;
int month;
age = auto.nextInt();
if(age == 1);
System.out.println(age);
System.out.println("Now... Tell me which month it is");
month = auto.nextInt();
System.out.println("Your lucky number is:"); System.out.println(month + age);
switch(age){
case 1:
System.out.println("You can crawl");
System.out.println("And you are to young to do this test, error!");
break;
case 2:
System.out.println("You can talk");
break;
case 3:
System.out.println("You can get into trouble");
break;
default:
System.out.println("My knowledge doesn't reach that far!");
break;
}
}
}
This is how it turns out:
Tell me how old you are and i will tell you what you can do
1
1
Now... Tell me which month it is
2
Your lucky number is:
3
You can crawl
And you are to young to do this test, error!
I want the You can crawl after: "Tell me how old you are and i will tell you what you can do" and just only one 1 here:
Tell me how old you are and i will tell you what you can do
1
1
Now... Tell me which month it is
Sorry for the long post. Kind of a newbie.
Thanks!