Question

In: Computer Science

Create a Java application to simulate a “GradeBook”. A teacher has five students who have taken...

Create a Java application to simulate a “GradeBook”. A teacher has five students who have taken four exams. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four exam scores:

Average

Letter Grade

90 – 100

A

80 – 89

B

70 – 79

C

60 – 69

D

0 – 59

F

Write logic to create a String array to hold student names, a character array to hold student letter grades, and a two-dimensional array to hold each of the five students’ test scores for each of the four exams completed during the semester.

Use nested for loop logic to fill the names and test scores arrays. Do not accept test scores less than zero or greater than 100. Make sure you test both ends of the range!

Use another nested for loop to compute the average test score for each student and then assign the corresponding letter the letter grade array. Make sure you test each letter grade value!

Use while loop logic to display a table showing each student’s name and letter grade.

Solutions

Expert Solution

Code - Main.java

import java.util.*;
public class Main
{
   public static void main(String[] args) {
   //Scanner to read user input
   Scanner sc = new Scanner(System.in);
   //array declared and variables
   String sName[] = new String[5];
   char grade[] = new char[5];
   int testScore[][] = new int[5][4];
   int i,j;
   int average[] = new int[5];
   //Nested for loop to get the student and marks for the corresponding student in 4 subject
   for(i = 0;i<sName.length;i++){
   System.out.println("Enter student name "+(i+1)+": ");
   sName[i] = sc.next();
   for(j=0;j<testScore[i].length;){
   System.out.println("Enter marks in "+(j+1)+" subject: ");
   testScore[i][j] = sc.nextInt();
   //if marks is greater than 100 and less than 0
   if(testScore[i][j]<0 || testScore[i][j]>100)
   System.out.println("Pls enter marks between 0 to 100");
   else
   j++;
   }
   System.out.println();
  
   }
   //for loop to calculate the average
   int sum;
   for(i = 0;i<testScore.length;i++){
   sum = 0;
   for(j=0;j<testScore[i].length;j++){
   sum += testScore[i][j];
   }
   average[i] = sum / testScore[i].length;
   }
   //for loop to calculate the grade
   for(i = 0;i<average.length;i++){
   if(average[i]>=90 && average[i]<=100){
   grade[i] = 'A';
   }
   else if(average[i]>=80 && average[i]<=89){
   grade[i] = 'B';
   }
   else if(average[i]>=70 && average[i]<=79){
   grade[i] = 'C';
   }
   else if(average[i]>=60 && average[i]<=69){
   grade[i] = 'D';
   }
   else if(average[i]>=0 && average[i]<=59){
   grade[i] = 'F';
   }
   }
   int count = 0;
   //while loop to print the result out
   while(count<sName.length){
   System.out.println("Student name: "+sName[count]+" grade: "+grade[count]);
   count++;
   }
  
   }
}

Screenshots -


Related Solutions

A teacher has five students who have taken four tests. The teacher uses the following grading...
A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores. -------------------------------------------------------------------- Test Score Letter Grade -------------------------------------------------------------------- 90 – 100 A >= 80 < 90 B >= 70 < 80 C >= 60 < 70 D < 60 F ------------------------------------------------------------------- Write a program that uses Python List of strings to hold the five student names,...
LAB3 YearGradeBook A teacher has 5 students who each will have 4 marking period scores. The...
LAB3 YearGradeBook A teacher has 5 students who each will have 4 marking period scores. The teacher uses the following grading scale to assign a year end letter grade to a student, based on the average of his or her 4 marking period scores. Marking Period Score                         Letter Grade 92-100                                                 A 83-91                                                   B 74-82                                                   C 65-73                                                   D 0-64                                                     F Write a class that uses a String array or an ArrayList object to hold the students’ names, an array of five...
Develop a Java application to simulate a game played in an elementary classroom. In this game,...
Develop a Java application to simulate a game played in an elementary classroom. In this game, the teacher places herself in the center of a circle of students surrounding her. She then distributes an even number of pieces of candy to each student. Not all students will necessarily receive the same number of pieces; however, the number of pieces of candy for each student is even and positive. When the teacher blows a whistle, each student takes half of his...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
Write a Java program to simulate the rolling of two dice. The application should use an...
Write a Java program to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12. Your application should roll the dice 36,000,000 times. Store the results of each roll...
This is in Java 1. Create an application called registrar that has the following classes: a....
This is in Java 1. Create an application called registrar that has the following classes: a. A student class that minimally stores the following data fields for a student:  Name  Student id number  Number of credits  Total grade points earned             And this class should also be provides the following methods:  A constructor that initializes the name and id fields  A method that returns the student name field  A method that returns the student...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls:...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls: A Label control with the following text displayed: "First Number:" A Label control with the following text displayed: "Second Number:" An empty TextField control beside the First Number label. An empty TextField control beside the Second Number label. Five buttons: Button 1 labeled + Button 2 labeled - Button 3 labeled * Button 4 labeled / Button 5 labeled = An empty Label control...
1. As a teacher, you have some students who clearly want to learn the subject matter...
1. As a teacher, you have some students who clearly want to learn the subject matter you are teaching and other students who are interested only in the grades they get in your class. a. Considering the textbook’s discussion of extrinsic versus intrinsic motivation, how would you expect the two groups of students to differ in terms of classroom learning and performance? Describe five differences you are likely to see between them. b. Describe three strategies you might use to...
1.Create full program in Java that will simulate a Rock Paper Scissors Game You will create...
1.Create full program in Java that will simulate a Rock Paper Scissors Game You will create the code so that when the program is run the user will see in the console the following: We are going to play rock paper scissors. Please choose 1 for Rock 2 for Paper or 3 for scissors. The program will have your choice which is the integer-valued typed in by the user and compChoice which will be the randomly generated value of either...
Create a Java application for Real Estates including Apartment and Homes. First, have a look at...
Create a Java application for Real Estates including Apartment and Homes. First, have a look at the class diagram that you will implement, and then read the explanation of these classes below. RealEstate (interface) + setId (String s) Apartment - id: String - surface: double + full argument constructor + getters and setters + setId (String s) + toString(): String Home - id: String - hasGarage: boolean + full argument constructor + getters and setters + setId (String s) +...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT