File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java beginer question

 
Tom Robert
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the help Pete! I am also getting an error on line 27 'void' type not allowed here.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Tom Robert
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 618
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your first post has the class name CalculatingTipsUseingInputDialog. Note the 'e' in 'Useing'
 
Tom Robert
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic