so i'm struggling with this problem which seems i cannot understand, im completely new in java and i need help.. so i am making a simple program which will determine if you have passed the subject or not via point grades and it seems it only determines the ELSE STATEMENT.. here's the code.. it will really help me out alot.. thanks in advance
String studID=" ",course=" ", name=" ", dept=" ", subj=" ";
double exam1=0, exam2=0, exam3=0, exam4=0;
double avg, pgrade;
String msg=" ";
studID =JOptionPane.showInputDialog("Please fill-out the following fields:"
+ "\nStudent ID: ");
name = JOptionPane.showInputDialog("Name: ");
dept = JOptionPane.showInputDialog("Department: ");
course = JOptionPane.showInputDialog("Course: ");
subj = JOptionPane.showInputDialog("Subject: ");
exam1 = Double.parseDouble(JOptionPane.showInputDialog("First Examination: "));
exam2 = Double.parseDouble(JOptionPane.showInputDialog("Second Examination: "));
exam3 = Double.parseDouble(JOptionPane.showInputDialog("Third Examination: "));
exam4 = Double.parseDouble(JOptionPane.showInputDialog("Final Examination: "));
avg = (exam1 + exam2 + exam3 + exam4)/4;
pgrade =(100 - avg + 10) / 10;
if (avg==100)
{
msg = "passed - Excellent!";
}else if (avg>100 && avg<89)
{
msg = "Passed - Very Good!";
}else if (avg>90 && avg<84)
{
msg = "Passed - Average";
}else if (avg>85 && avg<79)
{
msg = "Passed - Good";
}else if (avg>80 && avg<74)
{
msg = "Passed - Satisfactory";
}else if (avg>75 && avg<49)
{
msg = "Failed";
}else if (avg>50 && avg<0.00)
{
msg = "Dropped";
}else if (avg==0.00 && avg<0.00)
{
msg = "No such Grade";
}else
{
msg = "Out of Range or Invalid.";
}
JOptionPane.showMessageDialog(null, new JTextArea (
"|======Student Details=======|"
+ "\n|StudentID:\t" + studID +"\t |"
+ "\n|Name:\t" + name + "\t |"
+ "\n|Department:\t" +dept+ "\t |"
+ "\n|Course:\t"+course+"\t |"
+ "\n|Subject:\t"+subj + "\t |"
+ "\n|=======Grade Details======= |"
+ "\n|First Second Third Fourth |"
+ "\n|"+exam1+" "+exam2+" "+exam3+" "+exam4+"\t |"
+ "\n|Average:\t" +avg + "\t|"
+ "\n|Point Grade\t:" +pgrade+"\t|"
+ "\n|Remarks:"+msg+"\t|"
+ "\n|=============================|"));
}
}
Aucun commentaire:
Enregistrer un commentaire