i've never used java before and i need help!!
here is the description of what we have to do
Write a Java program that perform the following:
a. Prompts for user’s first name.
b. Prompts for user’s last name.
c. Prompts for user’s age.
The program should then display your full name (as last name, comma, first name), and age in days.
here is what i have so far, and im getting an error
import java.util.Scanner;
public class PlusTest
{
public static void main (String[] args)
{
Scanner scan = new Scanner (System.in);
System.out.println ("Enter your first name here:");
mary = scan.nextLine();
System.out.println ("You entered: \"" + mary+ "\"");
its saying that it cannot find symbol for mary... i dont know what to do here.
thanks for the help
Re: i've never used java before and i need help!!
You use a variable that has never been declared.
Re: i've never used java before and i need help!!
import java.util.Scanner;
public class PlusTest
{
public static void main (String[] args)
{
Scanner scan = new Scanner (System.in);
System.out.println ("Enter your first name here:");
String firstName = scan.nextLine();
System.out.println ("Enter your last name here:");
String lastName = scan.nextLine();
System.out.println ("Enter your birthday here:");
String birth = scan.nextLine();
System.out.println ("Name : " + firstName + lastName);
System.out.println ("Age : " + birth);
}
}
you should assign the type to your variable. The code I give you is just the thing following your previous code.
JAVA is a OOP language, generally, not all things happen in main.
Re: i've never used java before and i need help!!