473,472 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Student Records

4 New Member
I need help too figure out how to get the numbers 8, 9, 76,99 comment out of the code so when i run the program, that the user can input their own numbers.









public class StudentRecordDemo {

/**
* StudentRecordDemo main() is used to validate and verify
* that all of the methods and data members of the class
* do or contain what they are supposed.
*/
public static void main(String[] args) {
StudentRecord g1 = new StudentRecord();
g1.set(8, 9, 76, 99);
g1.writeOutput();
System.out.println("StudentRecordDemo done.");
}

public class StudentRecord {
// data members:
private int quiz1;
private int quiz2;
private int midterm;
private int finalExam;
private float finalGrade;
private char letterGrade;


// data methods:
/**
* StudentRecord.set() allows for the direct unverified input of data
* members of the class for use in testing and setting values.
*/
public void set(int q1, int q2, int mt, int fE) {
quiz1 = q1;
quiz2 = q2;
midterm = mt;
finalExam = fE;
finalGrade = computeFinalGrade();
letterGrade = computeLetterGrade();
}

public void writeOutput() {
System.out.println("Quiz 1 = " + quiz1);
System.out.println("Quiz 2 = " + quiz2);
System.out.println("Midterm Exam= " + midterm);
System.out.println("Final Exam = " + finalExam);
System.out.println("Final Grade = " + finalGrade + " or an ["
+ letterGrade + "]");
}

/**
* StudentRecord.computeFinalGrade() takes all test scores and provides the
* final computed class grade.
*/
private float computeFinalGrade() {
double tempGrade = 0.125 * (quiz1 * 10); // first quiz part
tempGrade += 0.125 * (quiz2 * 10); // second quiz part
tempGrade += 0.25 * midterm; // midterm part
tempGrade += 0.50 * finalExam; // final exam part
return (float) tempGrade;
}

/**
* StudentRecord.computeLetterGrade() provides correct letter grade for the
* final grade provided.
*/
private char computeLetterGrade()
{
char tempGrade = '?';
if (finalGrade >= 89.5)
tempGrade = 'A';
else if (finalGrade >= 79.5)
tempGrade = 'B';
else if (finalGrade >= 69.5)
tempGrade = 'C';
else if (finalGrade >= 59.5)
tempGrade = 'D';
else
tempGrade = 'F';
return tempGrade;
}
}
Oct 7 '06 #1
1 2282
r035198x
13,262 MVP
I need help too figure out how to get the numbers 8, 9, 76,99 comment out of the code so when i run the program, that the user can input their own numbers.









public class StudentRecordDemo {

/**
* StudentRecordDemo main() is used to validate and verify
* that all of the methods and data members of the class
* do or contain what they are supposed.
*/
public static void main(String[] args) {
StudentRecord g1 = new StudentRecord();
g1.set(8, 9, 76, 99);
g1.writeOutput();
System.out.println("StudentRecordDemo done.");
}

public class StudentRecord {
// data members:
private int quiz1;
private int quiz2;
private int midterm;
private int finalExam;
private float finalGrade;
private char letterGrade;


// data methods:
/**
* StudentRecord.set() allows for the direct unverified input of data
* members of the class for use in testing and setting values.
*/
public void set(int q1, int q2, int mt, int fE) {
quiz1 = q1;
quiz2 = q2;
midterm = mt;
finalExam = fE;
finalGrade = computeFinalGrade();
letterGrade = computeLetterGrade();
}

public void writeOutput() {
System.out.println("Quiz 1 = " + quiz1);
System.out.println("Quiz 2 = " + quiz2);
System.out.println("Midterm Exam= " + midterm);
System.out.println("Final Exam = " + finalExam);
System.out.println("Final Grade = " + finalGrade + " or an ["
+ letterGrade + "]");
}

/**
* StudentRecord.computeFinalGrade() takes all test scores and provides the
* final computed class grade.
*/
private float computeFinalGrade() {
double tempGrade = 0.125 * (quiz1 * 10); // first quiz part
tempGrade += 0.125 * (quiz2 * 10); // second quiz part
tempGrade += 0.25 * midterm; // midterm part
tempGrade += 0.50 * finalExam; // final exam part
return (float) tempGrade;
}

/**
* StudentRecord.computeLetterGrade() provides correct letter grade for the
* final grade provided.
*/
private char computeLetterGrade()
{
char tempGrade = '?';
if (finalGrade >= 89.5)
tempGrade = 'A';
else if (finalGrade >= 79.5)
tempGrade = 'B';
else if (finalGrade >= 69.5)
tempGrade = 'C';
else if (finalGrade >= 59.5)
tempGrade = 'D';
else
tempGrade = 'F';
return tempGrade;
}
}
Please use code tags for posting code next time you want to post code.
For taking input from the user, you use java.util.Scanner.
Since it's in the util package, you import it first before you use it
Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner;
Then in your code you make the scanner as follows

Expand|Select|Wrap|Line Numbers
  1. Scanner input = new Scanner(System.in);
meaning that it will read from the console.

Here is how I would use it to read a double value:
Expand|Select|Wrap|Line Numbers
  1. System.out.println("Enter a double : ");
  2. double myDouble  = input.nextDouble();
Oct 8 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Pieter Linden | last post by:
Hi, I think the subject line pretty much says it all... Say I have a students-classes database and I add a twist. I want to filter what courses a student can take by comparing the courses he...
1
by: mjobrien | last post by:
Thanks for the hint Allen (see below). But I am already doing that count as total records read (5)in the report footer. That count is unduplicated for the record not for the field - student ID as...
2
by: sallyk07 | last post by:
Modify the Student class so that each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the...
0
by: bonkeru | last post by:
Hi all am working on a project that keeps the student records and retrieve it can anybody help with a code in vb 6.0 that can solve my problem? It is urgent please. Thanks
3
by: angeldeveloper | last post by:
Hey Guys i need a pseudocode that should be look like this : Start Declare: lastName, finalGrade, outfile Open "grades.dat" For Output As outfile Write "Enter last name and final...
1
by: wetwetbarry | last post by:
student can see there score for test on a database records
2
by: nirav11 | last post by:
# include <iostream> # include <fstream> # include <iomanip> # include <cstdlib> // needed for exit () using namespace std; int main() { ifstream inFile; ofstream outFile;
3
by: praveenaj | last post by:
I was given to write a C program using Linked list to enter student marks, but i can't figure out how this node insertion works: how nodes are linked with each other??? A Computer Training...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.