Total members 11890 |It is currently Sat Apr 20, 2024 11:47 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





i'm having trouble with this commission program that i'm copying
from the java book i have from school. it only has you type the in
stubs. the first stub compiled with no errors but when i typed:



try
{
sales = Double.parseDouble(answer);
if (sales <= 0) throw new NumberFormatException();
else done = true;
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null, "Your entry was not in the
proper format.", "Error", JOptionPane.INFORMATION_MESSAGE);
}
then compiled the program again i ended up with these errors but
can't figure out why. could somebody please help? here's the code:
any help would be greatly appreciated. could somebody tell me the
best type of java to learn and the best book to learn it from. thnx



Code:

import javax.swing.JOptionPane;

import java.text.DecimalFormat;



public class Commission

{

public static void main(String[] args)

{

// declare class variables

double dollars, answer;

int empCode;



//call method

dollars = getSales();

}



//the getSales()method asks the user to input a dollar
amount and validates it

public static double getSales()

{

// declare method variables

double sales = 0.0;

boolean done = false;



//loop while not done

while(!done);



String answer = JOptionPane.showInputDialog
(null, "Enter the sales amount\n(do not use commas or dollar signs)\n
or click cancel to exit:");



if (answer == null) finish();



try

{

sales = Double.parseDouble
(answer);

if (sales <= 0) throw new
NumberFormatException();

else done = true;

}

catch(NumberFormatException e)

{

JOptionPane.showMessageDialog
(null, "Your entry was not in the proper format.", "Error",
JOptionPane.INFORMATION_MESSAGE);

}

}

return sales;

}



// the finish() method ends the program.

public static void finish()

{

System.exit(0);

}

}



C:\Documents and Settings\Owner\Desktop\Computer
Programming\Java\Commission.java:50: illegal start of type

return sales;


C:\Documents and Settings\Owner\Desktop\Computer
Programming\Java\Commission.java:50: <identifier> expected

return sales;

C:\Documents and Settings\Owner\Desktop\Computer
Programming\Java\Commission.java:54: 'class' or 'interface' expected

public static void finish()


C:\Documents and Settings\Owner\Desktop\Computer
Programming\Java\Commission.java:58: 'class' or 'interface' expected

}



C:\Documents and Settings\Owner\Desktop\Computer
Programming\Java\Commission.java:58: 'class' or 'interface' expected

}


C:\Documents and Settings\Owner\Desktop\Computer
Programming\Java\Commission.java:37: cannot resolve symbol

symbol : method finish ()

location: class Commission

if (answer == null) finish();



6 errors




Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

Thank you so much for your informative posts :sohappy:

commission de surendettement


Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

Thank you so much for your informative posts sonnerie portable mp3 - Sonnerie portable MP3 est en effet unpouvoir de l'innovation technologique. Êtes-vous familier avec cette sonnerie portable?


Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 3 posts ] 

  Related Posts  to : errors in commission program
 Program to compute commission using two methods     -  
 C program that displays shapes. Keep getting errors.     -  
 C++ DES Encryption Package - Errors?     -  
 BASE64Encoder/ BASE64Decoder & BadPaddingException errors.     -  
 HOW TO DO C++ PROGRAM?     -  
 java program     -  
 java program     -  
 how can i DeployPHP Program     -  
 what is the output of this program and how it be?     -  
 write a program in c++ for the following...     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com