...

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



Funnyjoe66
02-21-2012, 12: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!

alykins
02-21-2012, 01: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);

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum