| | |
Intro to Java help
![]() |
•
•
Join Date: Jul 2006
Posts: 3
Reputation:
Solved Threads: 0
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
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
This begs to be done using a student class heirarchy.
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.
Java Syntax (Toggle Plain Text)
class Student { String name; String ID; int midterm; int final; int course score; String letter grade; }
Last edited by iamthwee; Jul 9th, 2006 at 3:23 pm.
*Voted best profile in the world*
•
•
Join Date: Jul 2006
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by iamthwee
This begs to be done using a student class heirarchy.
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.Java Syntax (Toggle Plain Text)
class Student { String name; String ID; int midterm; int final; int course score; String letter grade; }
![]() |
Similar Threads
- Java program using scanner (Java)
- Review my applet (Java)
- Forum lurkers, introduce yourself ... !! (Community Introductions)
- Loop...without the loop (Java)
Other Threads in the Java Forum
- Previous Thread: help needed
- Next Thread: Learn Java - interactive way
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows






