# I need help with my code

• November 19th, 2011, 06:42 PM
ldmoore1981
I need help with my code
I need to accept inputs from users (doubles). It has to output the sum and the average. If the sum is over 100 there has to be a warning message that pops up. I have to use JOptionPane Here is the code that I have thus far. It is not working at all. Please help.

package PJ2aMooreD;

import javax.swing.JOptionPane ;

public class PJ2aMooreD {
private static double Num;
public static void main (String[] args) {

double Num1 ; // Declaring user inputs
double Num2 ;
double Num3 ;
double Num4 ;
double Num5 ;
double Num6 ;
double Num7 ;
double Num8 ;
double Num9 ;
double Num10 ;
string input ;

// Prompts user to enter 10 numbers
Num1 = double.parseDouble(input) ;
Num2 = double.parseDouble(input) ;
Num3 = double.parseDouble(input) ;
Num4 = double.parseDouble(input) ;
Num5 = double.parseDouble(input) ;
Num6 = double.parseDouble(input) ;
Num7 = double.parseDoublee(input) ;
Num8 = double.parseDouble(input) ;
Num9 = double.parseDouble(input) ;
Num10 = double.parseDouble(input) ;

// Calculates the sum and the average from the user’s input
double sum = (Num1 + Num2 + Num3 + Num4 + Num5 + Num6 + Num 7 + Num8 + Num9 + Num10) ;
double average = (sum / 3.0) ;

// Shows the message indicating the user’s average and sum
String avg = String.format("%.2f",average) ;
JOptionPane.showMessageDialog(null, "sum = " + sum + "\naverage = " + avg ) ;

// Returns a Warning Message based on the results from the user’s input
if(sum > 100) ;
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
if else ;

private static double stringparseDouble(string input) {
throw new UnsupportedOperationException("Not yet implemented");
}

private static double dstringparseDouble(string input) {
throw new UnsupportedOperationException("Not yet implemented");
}

private static class string {

public string() {
}
}

private static class sum {

public sum() {
}
}
JOptionPane.showMessageDialog(null, “No warning needed “) ;
}
• November 19th, 2011, 06:48 PM
Norm
Re: I need help with my code
Quote:

It is not working at all
Please explain what the problem is. Show the output or copy and paste the error messages to explain what the problem is.
• November 19th, 2011, 06:59 PM
ldmoore1981
Re: I need help with my code
when I hit debug this is the set of error messages I got:

run:
java.lang.NoClassDefFoundError: pj2amoored/PJ2aMooreD (wrong name: PJ2aMooreD/PJ2aMooreD)
at java.security.AccessController.doPrivileged(Native Method)
Exception in thread "main" Java Result: 1
• November 19th, 2011, 07:00 PM
Norm
Re: I need help with my code
Java is case sensitive. Check your spelling.
• November 19th, 2011, 07:03 PM
ldmoore1981
Re: I need help with my code
Here is what happened when I ran the program:

init:
profile-init:
deps-jar:
Updating property file: C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\build\built-jar.properties
init:
deps-clean:
Updating property file: C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\build\built-clean.properties
Deleting directory C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\build
clean:
Created dir: C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\build\classes
Created dir: C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\build\empty
Created dir: C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\build\generated-sources\ap-source-output
Compiling 8 source files to C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\build\classes
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:24: error: class expected
Num1 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:24: error: ';' expected
Num1 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:24: error: not a statement
Num1 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:24: error: ';' expected
Num1 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:26: error: class expected
Num2 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:26: error: ';' expected
Num2 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:26: error: not a statement
Num2 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:26: error: ';' expected
Num2 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:28: error: class expected
Num3 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:28: error: ';' expected
Num3 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:28: error: not a statement
Num3 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:28: error: ';' expected
Num3 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:30: error: class expected
Num4 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:30: error: ';' expected
Num4 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:30: error: not a statement
Num4 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:30: error: ';' expected
Num4 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:32: error: class expected
Num5 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:32: error: ';' expected
Num5 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:32: error: not a statement
Num5 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:32: error: ';' expected
Num5 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:34: error: class expected
Num6 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:34: error: ';' expected
Num6 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:34: error: not a statement
Num6 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:34: error: ';' expected
Num6 = double.parseDouble(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:36: error: class expected
Num7 = double.parseDoublee(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:36: error: ';' expected
Num7 = double.parseDoublee(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:36: error: not a statement
Num7 = double.parseDoublee(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:36: error: ';' expected
Num7 = double.parseDoublee(input) ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:38: error: class expected
Num8 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:38: error: ';' expected
Num8 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:38: error: not a statement
Num8 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:38: error: ';' expected
Num8 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:40: error: class expected
Num9 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:40: error: ';' expected
Num9 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:40: error: not a statement
Num9 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:40: error: ';' expected
Num9 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:42: error: class expected
Num10 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:42: error: ';' expected
Num10 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:42: error: not a statement
Num10 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:42: error: ';' expected
Num10 = double.parseDouble(input) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:47: error: ')' expected
double sum = (Num1 + Num2 + Num3 + Num4 + Num5 + Num6 + Num 7 + Num8 + Num9 + Num10) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:47: error: ';' expected
double sum = (Num1 + Num2 + Num3 + Num4 + Num5 + Num6 + Num 7 + Num8 + Num9 + Num10) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:56: error: illegal character: \8220
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:56: error: ';' expected
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:56: error: ';' expected
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:56: error: ';' expected
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:56: error: not a statement
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:56: error: ';' expected
JOptionPane.showMessageDialog(null, “Values have exceeded a sum of 100 ") ;"
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:57: error: '(' expected
if else ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:57: error: illegal start of expression
if else ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:57: error: ')' expected
if else ;
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:59: error: illegal start of expression
private static double stringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:59: error: ';' expected
private static double stringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:59: error: ';' expected
private static double stringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:59: error: ';' expected
private static double stringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:63: error: illegal start of expression
private static double dstringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:63: error: illegal start of expression
private static double dstringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:63: error: ';' expected
private static double dstringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:63: error: ')' expected
private static double dstringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:63: error: illegal start of expression
private static double dstringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:63: error: ';' expected
private static double dstringparseDouble(string input) {
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: <identifier> expected
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: illegal start of type
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: illegal character: \8220
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: ')' expected
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: ';' expected
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: illegal character: \8220
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: illegal start of type
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: <identifier> expected
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:78: error: ';' expected
JOptionPane.showMessageDialog(null, “No warning needed “) ;
^
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\src\pj2amoored\PJ2aMooreD.java:79: error: reached end of file while parsing
}
71 errors
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\nbproject\build-impl.xml:603: The following error occurred while executing this line:
C:\Users\Owner\Desktop\CMIS 141\ProjeCt 2\PJ2aMooreD\nbproject\build-impl.xml:245: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
• November 19th, 2011, 07:23 PM
Norm
Re: I need help with my code
Those are all compiler errors.

I suggest you start over. Delete ALL the code and start from the beginning. Start with a small program and add to it. Type in the minimum class definition with a very simple main method and compile it. Fix the errors and compile it. Continue fixing the code until there are no errors.
THEN Add a few lines, compile it again and fix the errors. Continue adding a few lines, compiling and fixing the errors.
That way you will never get this number of errors at one time.
• November 20th, 2011, 11:40 AM
andaji
Re: I need help with my code
Can you put your code and error in code tag? It's too hard and confusing to read through all these codes you gave here