Hi guys,

I'm currently taking a summer online intro to Java class (using Jcreator) and its kicking my butt! I might have to re-take it next semester to get a better understanding of how it works. I've been working on the same problem for the last 10 hours and I can't seem to make the codes work. Would someone please review it... I would really appreciate any input. ;)

Thanks a bunch! ~LB

Exercise Prompt: You need to develop a simple Student Grades program that allows instructors/professors to enter student information, including at a minimum their names and IDs, and their midterm and final scores. The name must contain at least one character (not a number). The ID must follow social-security-number format. Midterm and final must be scores between 0 and 100. The midterm counts for 40%; the final for 60%. Your program needs to calculate the course score (0-100) and the course grade, using the letter grading scale of our CIS-190 course (ref. Syllabus). Your program does not need to store information permanently, but it must be able to display a well-formatted table of multiple student records entered by the user with the six elements of information: name, ID, midterm, final, course score, and letter grade. You can use the console or a graphical look-and-feel.

What I have so far:

import java.util.Scanner; // program uses Scanner


public class StudentGrades
{
// main method begins execution of Java application
public static void main(String[] args) {
// determine Student Grades for CIS 190 {
System.out.printf("Welcome to the grade book for \n%s!\n\n",
"CIS 190 Online Java Programming");
} // end method display {


// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );


String name; // student name entered by user
int ssn; // student social security number entered by user
int grade1; // student's midterm grade
int grade2; // student's finals grade
int studentgrade; // student's current grade
int total; // sum of grade1 and grade2
int gradeCounter; // number of the grade entered


// initialization phase
int total = 0; // initialize total
int gradeCounter = 1; // initialize loop counter


// processing phase
while ( gradeCounter <=10 ) // loop 10 times
{
System.outprint("Enter student name: "); // prompt
name = input.nextDouble(); // input next name
System.outprint("Enter %n's Social Security Number: "); // prompt
ssn = input.nextDouble(); // input next ssn
System.outprint("Enter %n's midterm grade: "); // prompt
grade1 = input.nextDouble(); // input next grade1
System.outprint("Enter %n's finals grade: "); // prompt
grade2 = input.nextDouble(); // input next grade2
total = (grade1 * .04) + (grade2 * .06)


// determine current grade status
if (total >= 90 )
System.outprintln( "A" );
else
if (total >= 80 )
System.outprintln( "B" );
else
if (total >= 70 )
System.outprintln( "C" );
else
if (total >= 60 )
System.outprintln( "D" );
else
System.outprintln( "F" );
}// end while


// termination phase
System.out.printf( "%s%61s\n", "Name", "SSN", "Midterm",
"Finals", "Current Grade" ); // column headings
System.out.printf( "%61f%,20.2f\n", name, ssn, grade1, grade2, total);
// end for


}// end method main
}// end class StudentGrades
Member Avatar for iamthwee

This begs to be done using a student class heirarchy.

class Student
{
    String name; 
    String ID; 
    int midterm;
    int final;
    int course score; 
    String letter grade;
}

Then u can use the java swing to display it nicely. You should have notes how to do this? Although your assignment says you can do this just from the console window, so perhaps that may be easier than attempting to use a graphical interface.

This begs to be done using a student class heirarchy.

class Student
{
    String name; 
    String ID; 
    int midterm;
    int final;
    int course score; 
    String letter grade;
}

Then u can use the java swing to display it nicely. You should have notes how to do this? Although your assignment says you can do this just from the console window, so perhaps that may be easier than attempting to use a graphical interface.

Thanks iamthwee! I'll give it a try!

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.