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>

There are two loop structures that you can use in Java, the while and the for loop.
Do you know how to use these? If not, you should probably consult one of the 1.2 bazillion references that are available on the web, some of which are mentioned at the top of this forum (you must have seen them on the way in...) and get back to us.

The first thing you want to do is to use one of these structures to make this run forever. Then you can can work on getting it to stop.

Replace line 40 by the following code:

name=JOptionPane.showInputDialog("Enter Student's full Name:\nClick Cancel to terminate program");
if (name==null) {
	JOptionPane.showMessageDialog(null,"Bey for now.","Welcome to DANIWEB", JOptionPane.INFORMATION_MESSAGE);
	System.exit(0);
}

This is to set up a guard so that if client clicks cancel button, the program may terminate.

Replace your main method with the following method where the while loop seems endless. This is what jon.kiparsky said: " to use one of these structures to make this run forever ". However, the above guard may terminate the program by calling System.exit(0). Therefore, the while loop in fact does not run forever.

public static void main(String[] args)
{
 	Student s = new Student();
 	while(true){
	s.inputGrades();
	System.out.println("Average --> " + s.getAverage());
	System.out.println("Letter grade --> " + s.letterGrade());
	System.out.println("s.toString() --> " + s.toString());
	}
}

glamourhits,
as an exercise, you may create more JOptionPane window by the end of the while loop to ask cleint: " Would you like to enter another Student Grade " after each run.
Also you may use "break" instead of System.exit(0) to terminate the loop. Try different code.

Wow thank you very very much guys u guys rock >> :) ....

Thank you all
<fake signature snipped>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.