aspose file tools*
The moose likes Beginning Java and the fly likes Internet Delicatessen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Internet Delicatessen" Watch "Internet Delicatessen" New topic
Author

Internet Delicatessen

Jeffrey Samuel
Greenhorn

Joined: Oct 30, 2009
Posts: 2
Hi, I have a problem with this code. There are no errors but when I enter the item, tuna fish. It says InputMismatchException.

Here is the code I have so far.



Here is the question.

Sam and Ella's Delicatessen wants you to write a program to take orders from the Internet. Your program asks for the item, its price, and if overnight shipping is wanted. Regular shipping for items under $10 is $2.00; for items $10 or more shipping is $3.00. For overnight delivery add $5.00.

Enter the item:
Tuna Salad
Enter the price:
450
Overnight delivery (0==no, 1==yes)
1

Invoice:
Tuna Salad 4.50
shipping 7.00
total 11.50
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

You are declaring item as an integer, when I think you really want a string.

-Hunter


"If the facts don't fit the theory, get new facts" --Albert Einstein
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1732
    
  12

you should not capitalize your variable names.....

And your statement for overnight delivery does not match the spec requirements.

Janeice


When you do things right, people won't be sure you've done anything at all.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40028
    
  28
And when you get to printing, you will get many many outputs.
Have you been taught to put so much in the main method? That isn't object-oriented programming.
Why are you asking whether overnight < 0? Why are you getting overnight as a number at all?
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1732
    
  12

Campbell Ritchie wrote:
Why are you asking whether overnight < 0? Why are you getting overnight as a number at all?


I couldn't figure out why either.... but it looks like it's part of the spec. 0 is no, 1 is yes. A very binary setup.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40028
    
  28
It doesn't say "enter 0 for yes or 1 for no" or anything similar. It looks a bit like C code where you use 1 for true and 0 for false. It also looks like an out-by-one error because the way it is written it will take 0 or 1 both as "no".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internet Delicatessen