views:

48

answers:

3

I'm writing a program for my intro to Java class. I'm getting an error message, and I can't figure out what exactly it's telling me or how to resolve the issue. This is the message:

packageCost.java:17: incompatible types
found   : void
required: java.lang.String
                input = System.out.print("Please enter the weight of " +
                                        ^
packageCost.java:22: incompatible types
found   : void
required: java.lang.String
                input = System.out.print("How many miles is this " +
                                        ^
2 errors

Any help would be appreciated.

+2  A: 

better:

String input = System.console().readLine("Please enter the ..");
irreputable
+2  A: 

Your attempting to assign a String to "System.out.print("Please enter..");

System.out.print returns "void" which is not String, thus incompatible types.

It looks like your trying to do console input. You could use a Scanner to do this.

Try something like

Scanner scanner = new Scanner(System.in);
System.out.println("Enter input: ");
String input = scanner.nextLine();

Read about Scanner class, Just google it.

Andy Pryor
If I had the rep, -1 for being rude. We all have to start somewhere - stackoverflow is not just for current professionals. At least this isn't a homework question.
Tim Joseph
rude!!Very discouraging!!
bhargava
Was not trying to be rude, that sounded more rude than I intended. I spent three years as a Teaching Assistant, and I'm just saying Programming is a difficult thing to learn without studying and paying attention in class. :)
Andy Pryor
No worries- I'm taking an intro to java class online, so i'm basically given reading material and have to teach myself. We only covered scanner class last week, and i was writing an if else if input program and neglected to add the scanner.
Jett
+3  A: 

System.out.print does not return anything and you are trying to collect its return value in a variable.

codaddict