Question

Programmed in Java Pls - The other answer to this question is incorrect.: Your program should...

Programmed in Java Pls - The other answer to this question is incorrect.:

Your program should follow the below requirements:

  1. You will only need one class for this project called StudentReport in the package ilstu.edu
  2. In your class you will have the following instance variables:
    1. grades: a double 2d array that will hold the grades for all the students.
    2. Students: a 1d String array that will hold the names of all the students.
  3. In your class you will have the following methods:
    1. main:
      1. It will control the flow of your program.
      2. It will prompt the user to select one of the following options:
        1. Print a list of all students

This will print out all the student names to the console.

    1. Generate a report card for a specific student
      1. If selected it will ask the user to enter the name of the student
      2. It will then call the writeFile method to generate the report card
    2. Display statistics.
      1. It will print out the average of the class, the highest total and the lowest total.
  1. readFile:
    1. it will read the .csv file and store the values in the arrays we have.
  2. writeFile:
    1. it will generate a report card for the selected student and save it as a .txt file.
  1. You can add any methods and variables you find suitable.
  2. Your report file could have any formatting, but it should include the following:
    1. The student’s name
    2. Their grade in every exam, assignment with the appropriate label.

For example: Exam one: 50.

  1. Their Total.
  2. Their letter grade. (90 and above A, 80-89 B,70-79 C, 60-69 D, below 69 F)

Please comment and I will reply to it with a link to grades.csv

Thank you!

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

// studentExams.csv

Hannah Abbott   9   10   10   10   9   14   13   15
Amelia Bones   7   7   10   9   10   15   15   18
Michael Corner   8   9   10   8   10   14   15   19
Vincent Crabbe   6   5   8   5   10   15   15   20
Marcus Flint   10   6   10   8   10   12   15   20
Gregory Goyle   9   3   10   5   5   14   12   15
Rolanda Hooch   8   10   10   10   10   13   15   17
Angelina Johnson   9   1   5   8   10   10   11   16
Viktor Krum   10   0   6   5   10   14   15   14
Neville Longbottom   8   10   10   5   10   15   14   18
Theodore Nott   4   10   8   9   10   10   15   14
Irma Pince   10   8   10   8   10   15   14   15
Stan Shunpike   3   9   10   9   10   15   13   12
Alicia Spinnet   9   5   6   5   9   11   12   14
Emmeline Vance   5   8   2   3   9   12   11   15
Myrtle Warren   10   5   8   4   9   13   10   16
Oliver Wood   8   7   9   10   9   15   10   18
Rose Weasley   10   9   10   9   10   14   15   19
Blaise Zabini   4   0   2   3   5   9   8   10

=========================

// StudentExams.java

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

import sun.print.resources.serviceui;

public class StudentExams {

   public static void main(String[] args) throws IOException {
       int cnt = 0;
       Scanner sc = new Scanner(new File("studentExams.csv"));

       while (sc.hasNext()) {
           sc.nextLine();
           cnt++;
       }
       sc.close();

       String names[] = new String[cnt];
       int Students[][] = new int[cnt][8];

       sc = new Scanner(new File("studentExams.csv"));
       for (int i = 0; i < cnt; i++) {
           names[i] = sc.next() + " " + sc.next();
           for (int j = 0; j < 8; j++) {
               Students[i][j] = sc.nextInt();
           }
       }
       sc.close();


       /*
       * Creating an Scanner class object which is used to get the inputs
       * entered by the user
       */
       sc= new Scanner(System.in);
      
       while (true) {
           System.out.println("\n1.Print a list of all students");
           System.out.println("2.Generate a report card for a specific student");
           System.out.print("Enter Choice :");
           int choice = sc.nextInt();

           switch (choice) {
           case 1: {
              
                   displayNames(names);
              
           }
               break;

           case 2: {
               sc.nextLine();
               System.out.print("Enter Student name :");
               String name=sc.nextLine();
               int indx=searchName(name,names);
               if(indx==-1)
               {
                   System.out.println(name+" not found.");
               }
               else
               {
                   FileWriter fw=new FileWriter(new File("reportCard.txt"));
                   fw.write(names[indx]+"\n");
                   fw.write("Home Work one:"+Students[indx][0]+"\n");
                   fw.write("Home Work two:"+Students[indx][1]+"\n");
                   fw.write("Home Work three:"+Students[indx][2]+"\n");
                   fw.write("Quiz one:"+Students[indx][3]+"\n");
                   fw.write("Quiz two:"+Students[indx][4]+"\n");
                   fw.write("Exam one:"+Students[indx][5]+"\n");
                   fw.write("Exam two:"+Students[indx][6]+"\n");
                   fw.write("Final exam:"+Students[indx][7]+"\n");
                   fw.write("Total :"+calTotal(Students[indx])+"\n");
                  
                   char ch=gradeLetter(calTotal(Students[indx]));
                   fw.write("Grade Letter :"+ch+"\n");
                   double avg=calcAverage(Students);
                   fw.write("Class Average :"+avg+"\n");
                   int max=highest(Students);
                   int min=lowest(Students);
                   fw.write("Minimum Total :"+min+"\n");
                   fw.write("Maximum Total :"+max+"\n");
                   fw.close();
                  
                  
               }
               break;
           }
           default: {
               System.out.println("** Invalid Choice **");
               continue;
           }
           }
           break;

       }

   }

   private static int lowest(int[][] students) {
       int min=calcTot(students[0]);
       for(int i=0;i<students.length;i++)
       {
           if(min>calcTot(students[i]))
           {
               min=calcTot(students[i]);
           }
       }
       return min;
   }

   private static int calcTot(int[] scores) {
       int tot=0;
       for(int i=0;i<scores.length;i++)
       {
           tot+=scores[i];
       }
       return tot;
   }

   private static int highest(int[][] students) {
       int max=calcTot(students[0]);
       for(int i=0;i<students.length;i++)
       {
           if(max<calcTot(students[i]))
           {
               max=calcTot(students[i]);
           }
       }
       return max;
   }

   private static double calcAverage(int[][] students) {
       int tot=0;
       for(int i=0;i<students.length;i++)
       {
           for(int j=0;j<students[0].length;j++)
           {
               tot+=students[i][j];
           }
       }
       return ((double)tot/((students.length)));
   }

   private static char gradeLetter(int average) {
      
       char gradeLet=0;
       if (average >= 90 && average<=100)
           gradeLet = 'A';
           else if (average >= 80 && average < 90)
           gradeLet = 'B';
           else if (average >= 70 && average < 80)
           gradeLet = 'C';
           else if (average >= 60 && average < 70)
           gradeLet = 'D';
           else if (average < 60)
           gradeLet = 'F';
       return gradeLet;
   }

   private static int calTotal(int[] scores) {
       int tot=0;
       for(int i=0;i<scores.length;i++)
       {
           tot+=scores[i];
       }
       return tot;
      
   }

   private static int searchName(String name, String[] names) {
       for(int i=0;i<names.length;i++)
       {
           if(names[i].equalsIgnoreCase(name))
           {
               return i;
           }
       }
       return -1;
   }

   private static void displayNames(String[] names) {
System.out.println("Displaying the Student names :");
for(int i=0;i<names.length;i++)
{
   System.out.println(names[i]);
}
   }
}

===========================

Output#1:

1.Print a list of all students
2.Generate a report card for a specific student
Enter Choice :1
Displaying the Student names :
Hannah Abbott
Amelia Bones
Michael Corner
Vincent Crabbe
Marcus Flint
Gregory Goyle
Rolanda Hooch
Angelina Johnson
Viktor Krum
Neville Longbottom
Theodore Nott
Irma Pince
Stan Shunpike
Alicia Spinnet
Emmeline Vance
Myrtle Warren
Oliver Wood
Rose Weasley
Blaise Zabini

=======================

Output#2:


1.Print a list of all students
2.Generate a report card for a specific student
Enter Choice :2
Enter Student name :Oliver Wood

reportCard.txt (output file)

=============================Thank You

Add a comment
Know the answer?
Add Answer to:
Programmed in Java Pls - The other answer to this question is incorrect.: Your program should...
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
  • IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the...

    IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then outputs the average grade for each student. It also outputs the highest grade a student earned in each test, and the average of all grades in each test. Your output should look like this: Mary's average grade was 78.8% Harry's average grade was 67.7% etc... : In test 1 the highest grade was 93% and...

  • This code should be written in php. Write a program that allows the user to input...

    This code should be written in php. Write a program that allows the user to input a student's last name, along with that student's grades in English, History, Math, Science, and Geography. When the user submits this information, store it in an associative array, like this: Smith=61 67 75 80 72 where the key is the student's last name, and the grades are combined into a single space-delimited string. Return the user back to the data entry screen, to allow...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

  • IN C You will be creating a program to help a teacher calculate final grades for...

    IN C You will be creating a program to help a teacher calculate final grades for a class. The program will calculate a final letter grade base on a standard 90/80/70/60 scale. You will be taking input from a file that contains all of the names and grades of each student. You will find the average for each student and output each student's final letter grade. Your program should accept the filename from the command-line Add error checking to make...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • Write a Java program that reads a file until the end of the file is encountered....

    Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...

  • For C++ program Your program should first prompt the user for the number of students they...

    For C++ program Your program should first prompt the user for the number of students they wish to enter. For each student, the user will be prompted to enter the student’s name, how many tests the student has taken, and the grade for each test. Each test’s grade will be inputted as a number representing the grade for that test. Once each student’s information has been entered, the program will display the number of students. Additionally, each student will have...

  • Write a program in Java according to the following specifications: The program reads a text file...

    Write a program in Java according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "print" - prints the student records (first name, last name, grade). "sortfirst" - sorts the student records by first name. "sortlast" - sorts the student records by last name. "sortgrade" - sorts the...

  • Create a class called Student. This class will hold the first name, last name, and test...

    Create a class called Student. This class will hold the first name, last name, and test grades for a student. Use separate files to create the class (.h and .cpp) Private Variables Two strings for the first and last name A float pointer to hold the starting address for an array of grades An integer for the number of grades Constructor This is to be a default constructor It takes as input the first and last name, and the number...

  • Using Java, write a program that teachers can use to enter and calculate grades of individual...

    Using Java, write a program that teachers can use to enter and calculate grades of individual students by utilizing an array, Scanner object, casting, and the print method. First, let the user choose the size for the integer array by using a Scanner object. The integer array will hold individual assignment grades of a fictional student. Next, use a loop to populate the integer array with individual grades. Make sure each individual grade entered by the user fills just one...

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