View Full Version : Why isn't this code working?

02-21-2012, 01:57 AM
This is the code:

import Java.util.Scanner

public class Myknowledgeof_feb2012 {
public static void main(String[] args) {
java.util.Scanner sc=new Scanner (System.in);

System.out.println("How are you doing?") ;

String s= sc.nextLine();
System.out.print("You are feeling (s)") ;



I know its rudimentary and basic, but I'm a beginner. But seriously: Eclipse says that "Scanner cannot be resolved to a type". I dunno. Please help! This basic thing will allow me to continue my at-home studies!

02-21-2012, 02:56 AM
I did not get any errors when I compiled you code that you posted... the only thing is it printed (s)... try this to get the correct string formatting

Scanner keyboard = new Scanner(System.in);
System.out.println("How are you today?");
String demo = keyboard.nextLine();
System.out.printf("You are feeling %s", demo);

02-21-2012, 05:15 AM
Thank-you! I wasn't sure how to imbed a value into a string, so I tryed that - and it worked. TNX!