Reputation: 183
I have this assignment in school, where I have to import a scanner and write a method. What am I doing wrong?
public static void main(String[] args)
{
applicationDate();
}
public static void applicationDate()
{
Scanner input = new Scanner(System.in);
System.out.println("On what day of the month you applied?");
int day = input.nextInt();
System.out.println("What is the name of the month in wich you applied?");
String month = input.nextLine();
System.out.println("During wich year you applied?");
int year = input.nextInt();
System.out.print("Your application date is" + month + " ", + year + "!");
}
It comes with this error when I compile the thing, EX20.java:27: cannot find symbol
Upvotes: 0
Views: 167
Reputation: 159844
print
only takes one String
argument - move the comma inside the String
System.out.print("Your application date is" + month + " ," + year + "!");
^
Upvotes: 3
Reputation: 53038
First add import java.util.Scanner;
to your file.
As this line is missing you must be getting error as
error: cannot find symbol
Scanner input = new Scanner(System.in);
^
then
Remove extra comma from the last print statement.
System.out.print("Your application date is" + month + " ,"+ year + "!");
Upvotes: 1
Reputation: 2861
Remove comma and add it in between double quotes like below.
System.out.print("Your application date is" + month + " ,"+ year + "!");
Upvotes: 2