Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
import javax.swing.*;
public class failornot {
public static void main (String args[]) {
String s1=JOptionPane.showInputDialog("NAME ? ");
int s2=Integer.parseInt(JOptionPane.showInputDialog("H OMEWORKS POıNTS ? "));
int s3=Integer.parseInt(JOptionPane.showInputDialog("M IDTERM POINTS ? "));
int s4=Integer.parseInt(JOptionPane.showInputDialog("F INAL POINTS ? "));
double achieve=0.25*s2+0.35*s3+0.4*s4;
String z=" DEAR "+s1;
if(achieve < 60)
{z+=" YOU FAILED. GAME OVER ";
JOptionPane.showMessageDialog(null,z,JOptionPane.W ARNING_MESSAGE);}
{z+=" CONGRATULATIONS ";
JOptionPane.showMessageDialog(null,z,JOptionPane.P LAIN_MESSAGE);}
}
}
Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
Oh my. Do you really write your code in giant red comic sans?
Use the highlight tags instead.
Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
It's okay, but you still haven't used the highlight tags.
I'm also not sure what your question is. What does this code do? Does it compile? Does it throw an Exception? If so, what line is the problem on?
Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
You didn't use the highlight tags.
Also, what is your error?
EDIT: Oh, you have an if/else statement, with a block for the if and a block for the else, but you never use the else keyword. An if/else statement looks like this:
Code java:
if(someCondition) {
//Do something
}
else { //<-- You forgot this else keyword
//Do Something
}
Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
really thanks for the replies. i solved my problem. i'll back soon with my new problems. :)
Re: Easy error to solve in a minute. Help please, I don't want to fail Java Programming again.
Quote:
Originally Posted by
ihatejava
really thanks for the replies. i solved my problem. i'll back soon with my new problems. :)
Glad it is working, and good luck on your new problems. Please mark threads as solved when your questions have been answered.