Question

Create a Student grading system. You should use a person base class (stores the name of...

Create a Student grading system. You should use a person base class (stores the name of the student). Derive a student class from the person class. The student class stores the student ID. The student class should also store the students 3 exams (Test 1, Test 2, and Test 3) and calculate a final grade (assume the 3 tests count equally). Create an array of students for a class size of 15 students. You can use the keyboard to read in all of the data for the 15 students (name, ID, and 3 grades), or read this data from a text file (PrintWriter). If using a text file, you can use Comma Seperated values (see Case study in Chapter 10 page 748 for examples how to do this), below also shows how you can read CSV (see below).

String line = "4039,50,0.99,SODA" String[] ary = line.split(","); System.out.println(ary[0]); // Outputs 4039 System.out.println(ary[1]); // Outputs 50 System.out.println(ary[2]); // Outputs 0.99 System.out.println(ary[3]); // Outputs SODA Once all the data is Imported, you can average all the exams and create a final letter grade for all students.

A - 90-100

B - 80-89

C - 70-79

D - 64-69

F < 64

The program should create an output showing all the data for each student as well as writing all the results to a file (using PrintWrite class).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//file name: Student.java

import java.io.*;
import java.util.*;
class Person{
   String name;
   Person(String name)
   {
       this.name = name; // assining name to studet name.
   }
}
class Student extends Person{ //sub class(Student) extends to super class Person
   //instance variables.
   String studentId;
   int test1,test2,test3;
   //parameterized constructor.
   Student(String name,String studentId,int test1,int test2,int test3)
   {
       super(name); // assinging student name to super class.
       this.studentId = studentId;
       this.test1=test1;
       this.test2=test2;
       this.test3=test3;
   }
   String computeGrade() //function to compute grades.
   {
       int sum = test1+test2+test3;
       double avg = sum/3;
       if(avg>=90)
       {
           return "A";
       }
       if(avg>=80)
       {
           return "B";
       }
       if(avg>=70)
       {
           return "C";
       }
       if(avg>=64)
       {
           return "D";
       }
       else{
           return "F";
       }
   }
}
class driverClass{
   public static void main(String[] args)throws IOException {
       FileReader fr=null; // for opening and reading a input file.
       BufferedReader br =null;//reading file line by line.
       PrintWriter fw =null; // for writing a file
       String line="";
       try
       {
           fr = new FileReader(new File("input.txt")); // opening a file
           br = new BufferedReader(fr); // instance assining to buffered reader.
           fw = new PrintWriter(new File("output.txt")); // creating a output file for writing.
       }
       catch(Exception e) // exception handling incase of file not found.
       {
           System.out.println("File not found");
       }
       fw.append("name,id,test1,test2,test3,grade "); //appending header to output file.
       while((line=br.readLine())!=null) // reading line by line from input file.
       {
           String arr[] = line.split(","); //splitting input file based on coma(',')
           // passing parameters to student class and creating object for student class.
           Student student = new Student(arr[0],arr[1],Integer.parseInt(arr[2]),Integer.parseInt(arr[3]),Integer.parseInt(arr[4]));
           String grade = student.computeGrade(); //calling compute function to compute the grade.
           fw.append(line+","+grade+" "); //writing student data to outputfile.
       }
       fr.close(); //closing the file reader
       fw.close(); //closing the printwriter.
      
   }
}

//input file name: input.txt

/*

bhargavi,156887,43,66,78
bhanu,121825,67,79,65
anitha,151845,44,99,89
sravs,171856,67,77,79
ravi,111887,84,80,89
yedu,121856,55,85,79
sravanthi,171687,89,84,99
naseem,131484,67,89,29
bhuvana,181857,90,70,39
pavani,151837,45,30,79
paddu,181981,90,40,79
ramu,101896,98,60,79
pravallika,101881,87,70,69
ramana,121887,78,80,69
rahul,121887,66,80,89

*/

//compiling.

//output file

Add a comment
Know the answer?
Add Answer to:
Create a Student grading system. You should use a person base class (stores the name of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java - In NetBeans IDE: • Create a class called Student which stores: - the name...

    Java - In NetBeans IDE: • Create a class called Student which stores: - the name of the student - the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into...

  • You will create a class to keep student's information: name, student ID, and grade. The program...

    You will create a class to keep student's information: name, student ID, and grade. The program will have the following functionality: - The record is persistent, that is, the whole registry should be saved on file upon exiting the program, and after any major change. - The program should provide the option to create a new entry with a student's name, ID, and grade. - There should be an option to lookup a student from his student ID (this will...

  • Use C++ to create a class called Student, which represents the students of a university. A...

    Use C++ to create a class called Student, which represents the students of a university. A student is defined with the following attributes: id number (int), first name (string), last name (string), date of birth (string), address (string). and telephone (area code (int) and 7-digit telephone number(string). The member functions of the class Student must perform the following operations: Return the id numb Return the first name of the student Modify the first name of the student. . Return the...

  • Create a java project and create Student class. This class should have the following attributes, name...

    Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...

  • Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Ini...

    Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...

  • FOR JAVA: Summary: Create a program that adds students to the class list (see below). The...

    FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...

  • A teacher wants to create a list of students in her class. Using the existing Student...

    A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static ArrayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList. Coding below was given to edit and use public class ClassListTester { public static void main(String[] args) { //You don't need to change anything here, but feel free...

  • Last picture is the tester program! In this Assignment, you will create a Student class and...

    Last picture is the tester program! In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...

  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • Write a Student class that stores information for a Montclair student. The class should include the...

    Write a Student class that stores information for a Montclair student. The class should include the following instance variables id, an integer identifier for the student lastName, a string for the student's last name creditsEarned, an integer representing the number of course-credits the student has earned courseLoadCredits, an integer representing the current number of credits in progress. status, an integer representing the status of the student (1 means freshman, 2 means sophomore, 3 means junior, 4 means senior). This status...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT