wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Java beginer question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java beginer question" Watch "Java beginer question" New topic
Author

Java beginer question

Tom Robert
Greenhorn

Joined: Sep 15, 2010
Posts: 6
I need to write a program that reads the subtotal and the gratuity rate, then computes the gratuity and total. Im getting a couple errors can anyone help me out?
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Welcome to JavaRanch!

First and foremost, you'll want to have a look at our FAQ on how to ask questions at JavaRanch as it will greatly help you to get decent answers, including how to use code tags at JavaRanch. You'll also want to post full error messages if you have any and indicate the line number causing the error.

Next as to one of your problems, your class name is two words, NewClass CalculatingTipsUseingInputDialog, where only one is allowed.
Tom Robert
Greenhorn

Joined: Sep 15, 2010
Posts: 6
Thank you for the help Pete! I am also getting an error on line 27 'void' type not allowed here.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

It's line 28 in the code you posted. It's because JOptionPane.showMessageDialog(null,output); returns void. And that is not allowed to concatenate with a String.
You probably meant:


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Tom Robert
Greenhorn

Joined: Sep 15, 2010
Posts: 6
Oh ok I see what i did wrong there thanks Wouter. As far as my class name being two words I am not sure what you mean. I am sorry for the simple questions I am very new to java.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Well the name of your class is "NewClass CalculatingTipsUsingInputDialog" which are 2 words which is not allowed. It can only be one word. So I assume you want it to be just "CalculatingTipsUsingInputDialog".
Tom Robert
Greenhorn

Joined: Sep 15, 2010
Posts: 6
ok when I change my class name to that I now get the error class "CalculatingTipsUsingInputDialog is public, should be declared in a file named CalculatingTipsUsingInputDialog.java"
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Your first post has the class name CalculatingTipsUseingInputDialog. Note the 'e' in 'Useing'
Tom Robert
Greenhorn

Joined: Sep 15, 2010
Posts: 6
OK I found the problem I had the class name as New Class.java I changed it to CalculatingTipsUsingInputDialog.java and everything runs fine. Thank you everyone for your help.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You're welcome
 
 
subject: Java beginer question
 
Similar Threads
repeating code
calculating real estate commissions
calculating commission
displaying total amounts
Help me figure out my logic error