Forums Register Login

Java beginer question

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thank you for the help Pete! I am also getting an error on line 27 'void' type not allowed here.
+Pie Number of slices to send: Send
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:
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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".
+Pie Number of slices to send: Send
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"
+Pie Number of slices to send: Send
Your first post has the class name CalculatingTipsUseingInputDialog. Note the 'e' in 'Useing'
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
You're welcome
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4327 times.
Similar Threads
calculating commission
repeating code
displaying total amounts
calculating real estate commissions
Help me figure out my logic error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 16:34:22.