Here Is My Code i am done with it and it works fine but i want to make this run in loop . like i want this program to ask Would you like to enter another Student Grade <Y/N>...
Here Is the Code .. If Any 1 Can Help Plz Do .. THank YOu Very MUch
import javax.swing.JOptionPane;
public class Student {
public static void main(String[] args)
{
Student s = new Student();
s.inputGrades();
System.out.println("Average --> " + s.getAverage());
System.out.println("Letter grade --> " + s.letterGrade());
System.out.println("s.toString() --> " + s.toString());
}
final double As1 = .10;
final double As2 = .10;
final double As3 = .10;
final double As4 = .10;
final double MID_Grade = .25;
final double Final_Grade = .25;
final double Participation = .10;
String name, finalLetterGrade;
int assignmentOne = 0;
int assignmentTwo = 0;
int assignmentThree = 0;
int assignmentFour = 0;
int midterm = 0;
int finalExamGrade = 0;
int participation = 0;
double finalNumericGrade = 0;
public Student() {
System.out.println (" Inputting Student Grades ...");
}
public void inputGrades() {
name=JOptionPane.showInputDialog("Enter Student's full Name:");
assignmentOne = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment One Grade" ));
assignmentTwo = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment Two Grade" ));
assignmentThree = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment Three Grade" ));
assignmentFour = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Assignment Four Grade" ));
midterm = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Midterm Grade" ));
finalExamGrade = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Final Examination Grade" ));
participation = Integer.parseInt(JOptionPane.showInputDialog( "Enter the Participation Grade" ));
}
public double getAverage(){
finalNumericGrade =
(assignmentOne * As1) +
(assignmentTwo * As2) +
(assignmentThree * As3) +
(assignmentFour * As4) +
(midterm * MID_Grade) +
(finalExamGrade * Final_Grade) +
(participation * Participation);
return finalNumericGrade;
}
private String letterGrade(){
if (finalNumericGrade >= 93)
finalLetterGrade = "A";
else
if ((finalNumericGrade >= 85) & (finalNumericGrade < 93))
finalLetterGrade = "B";
else
if ((finalNumericGrade >= 78) & (finalNumericGrade < 85))
finalLetterGrade = "C";
else
if ((finalNumericGrade >= 70) & (finalNumericGrade < 78))
finalLetterGrade = "D";
else
if (finalNumericGrade < 70)
finalLetterGrade = "F";
return finalLetterGrade;
}
public String toString() {
String studentStringValue= " Student Name is: "+name +"\n";
studentStringValue+= " Assignment One grade is: " + assignmentOne + "\n";
studentStringValue+=" Assignment Two grade is: " + assignmentTwo + "\n";
studentStringValue+=" Assignment Three grade is: " + assignmentThree + "\n";
studentStringValue+=" Assignment Four grade is: " + assignmentFour + "\n";
studentStringValue+=" Midterm grade is: " + midterm + "\n";
studentStringValue+=" Final Exam is: " + finalExamGrade + "\n";
studentStringValue+=" Participation grade is: " + participation + "\n\n";
studentStringValue+=" Final Numeric Grade is: " + finalNumericGrade + "\n";
studentStringValue+=" Final Letter Grade is: " + finalLetterGrade +"\n";
return studentStringValue;
}
public void printName(){
System.out.print(" "+name);
}
}
PLZ TRY HELPHING ME OUT >> I AM REALLY NEW AT THIS >>> THANK YOU
<FAKE SIGNATURE SNIPPED>