Results 1 to 7 of 7
- 10-09-2011, 11:51 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 10
- Rep Power
- 0
Simple if code not working? Assistanc wanted.
Why is this code not working?
import java.util.Scanner;
public class DiningDollars {
private static Scanner keyboard = new Scanner (System.in);
private static final double SUB_COST = 5;
public static void main (String[] args);
System.out.println("How many dining dollars do you have? ");
double currentDollars = keyboard.nextDouble();
if (currentDollars < (SUB_COST * 3)) {
System.out.println("Take two friends to subway!");
currentDollars -= (SUB_COST*3);
}
System.out.println("You are now left with " + currentDollars);
}
}
- 10-09-2011, 11:55 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Re: Simple if code not working? Assistanc wanted.
"not working" might need a little elaboration: Does this code compile? If not and you can't understand the compiler's messages, post them and indicate the lines of your code to which they refer.
-
Re: Simple if code not working? Assistanc wanted.
- 10-10-2011, 12:04 AM #4
Member
- Join Date
- Sep 2011
- Posts
- 10
- Rep Power
- 0
Re: Simple if code not working? Assistanc wanted.
I'm getting errors on lines 9, 12, and 16. It's saying things like <identifier> expected, and illegal start of type, and ';' expected.
-
Re: Simple if code not working? Assistanc wanted.
- 10-10-2011, 12:16 AM #6
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Re: Simple if code not working? Assistanc wanted.
Sometimes the compiler will get *very* confused by a relatively simple mistake and spit out all sorts of messages for the subsequent code. The first thing to do in such cases is to look just above where the messages start.
- 10-10-2011, 12:23 AM #7
Member
- Join Date
- Sep 2011
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
Simple TCP Client/Server not working?!?!?!
By FiniteRed in forum NetworkingReplies: 1Last Post: 07-15-2011, 03:23 PM -
Simple servlet not working : entire source code posted
By rahulb in forum Java ServletReplies: 0Last Post: 05-24-2011, 07:50 AM -
Simple code not working
By davetheant in forum New To JavaReplies: 7Last Post: 02-04-2011, 12:51 AM -
Simple TCP chat application not working for me
By sundarrajan in forum New To JavaReplies: 0Last Post: 08-13-2009, 08:31 AM -
simple validations not working
By rahaman.athiq in forum Web FrameworksReplies: 0Last Post: 11-06-2008, 06:10 AM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks