need help with 1st homework lesson

Im learning how program in java and using eclipse ide to the course work.

the homework comes from this site https://programmingbydoing.com/a/asking-questions.html

on the scanner line i keep getting this error

"Multiple markers at this line

  • Scanner cannot be resolved
    to a type"

and i can not figure out why the copy and pasted code doesnt even work before i even modify it

the full code is

import java.util.Scanner;

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

		int age;
		String height;
		double weight;

		System.out.print( "How old are you? " );
		age = keyboard.nextInt();

		System.out.print( "How tall are you? " );
		height = keyboard.next();

		System.out.print( "How much do you weigh? " );
		weight = keyboard.nextDouble();

		System.out.println( "So you're " + age + " old, " + height + " tall and " + weight + " heavy." ); 
}
}

 any help would be greatly appretiated

I see nothing wrong with the code, which suggests an Eclipse problem and/or a configuration problem.

You might look at this Stack Overflow question and see if anything there helps.

You might try taking Eclipse out of the picture: you should be able to type

javac AskingQuestions.java

at the command line to compile your program. If that doesn’t work, you probably have a problem with your Java setup.

Hi @ajboyne,

Welcome to the GitHub Community forum!

I tried to compile and it give me no error, so i think the problem is in eclipse (like @fire-eggs said). I also tried to run in eclipse and give the same result without error.

At this point i think the problem is your version of eclipse or a issue with your java jdk.

Try to see if the java path of the system are correctly set or if the properties of the eclipse java project is using the right compliance.

-Gabriele-

Mark helpful posts with Accept as Solution to help other users locate important info. Don’t forget to give Kudos for great content!

1 Like

my classmate pointed out that in the code I put into eclipse I didn’t add the import line at the top, thank you tho

my classmate pointed out that in the code I put into eclipse I didn’t add the import line at the top, thank you tho