Question

In: Computer Science

2. Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a...

2. Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student gradebook using a two-dimensional array. It should allow the user to enter the number of students and the number of assignments they wish to enter grades for. This input should be used in defining the two-dimensional array for your program. For example, if I say I want to enter grades for 4 students and 5 assignments, your program should define a 4 X 5 array. Your program should allow the user to then enter the appropriate number of grades and store them within the twodimensional array. Your program should include an additional method that will display these values in a matrix form, with the student names on the left and the assignment names as the column header. After displaying the matrix, add a second method that will display each student’s grade average.

Solutions

Expert Solution

import java.util.*;

class Test
{

public static void main (String[] args)
{

String[] name = new String[4];

int[][] assignment = new int[4][5];

int[] gradeAverage = new int[4];

Scanner scan = new Scanner(System.in);
for(int i=0;i<4;i++)
{
System.out.println("Enter name and 5 assignment marks for student "+(i+1)+" : ");
name[i] = scan.next();
for(int j=0;j<5;j++)
{
   assignment[i][j] = scan.nextInt();
}
}


print(name,assignment);

print(name,assignment,gradeAverage);


}

public static void print(String[] name,int[][] assignment)
{
System.out.println("\n\n\nName\tAssignment1\tAssignment2\tAssignment3\tAssignment4\tAssignment5");
for(int i=0;i<4;i++)
{
System.out.print(name[i]+"\t\t");
for(int j=0;j<5;j++)
{
System.out.print(assignment[i][j]+"\t\t");
}
System.out.println();
}
  
}

public static void print(String[] name,int[][] assignment,int[] gradeAverage)
{
     
System.out.println("\n\n\nName\tGrade Average");
for(int i=0;i<4;i++)
{
   gradeAverage[i] = 0;
System.out.print(name[i]+"\t\t");
for(int j=0;j<5;j++)
{
gradeAverage[i]= gradeAverage[i] + assignment[i][j];
  
}
System.out.print(gradeAverage[i]/5);
System.out.println();
}
  
}


}

Output:

Enter name and 5 assignment marks for student 1 : Adams 56 74 75 83 65
Enter name and 5 assignment marks for student 2 : Belk 73 71 76 88 55
Enter name and 5 assignment marks for student 3 : Caan 86 64 78 81 69
Enter name and 5 assignment marks for student 4 : Dunn 66 84 79 65 64



Name    Assignment1     Assignment2     Assignment3     Assignment4     Assignment5
Adams           56              74              75              83              65              
Belk            73              71              76              88              55              
Caan            86              64              78              81              69              
Dunn            66              84              79              65              64              



Name    Grade Average
Adams           70
Belk            72
Caan            75
Dunn            71

Do ask if any doubt. Please upvote.


Related Solutions

Create a Netbeans project called LineNumbers The program should do the following: –Ask the user for...
Create a Netbeans project called LineNumbers The program should do the following: –Ask the user for how many lines of text they wish to enter –Declare and initialize an array of Strings to hold the user’s input –Use a while loop to prompt for and read the Strings (lines of text) from the user at the command line. Typically, this would be a 'for' loop since we know the number of times to execute the loop based upon the number...
Part 1 – Classes and objects Create a new Java project called usernamePart1 in NetBeans. In...
Part 1 – Classes and objects Create a new Java project called usernamePart1 in NetBeans. In my case the project would be called rghanbarPart1. Select the option to create a main method. Create a new class called Vehicle. In the Vehicle class write the code for: • Instance variables that store the vehicle’s make, model, colour, and fuel type • A default constructor, and a second constructor that initialises all the instance variables • Accessor (getters) and mutator (setters) methods...
Step 1: Create a new Java project in NetBeans called “Wedding1” Step 2: Use appropriate data...
Step 1: Create a new Java project in NetBeans called “Wedding1” Step 2: Use appropriate data types to store the following information: The names of the bride and groom The total number of guests at the wedding The square footage of the location (must be accurate to 0.1 square feet). The names of each song in the DJ's playlist. You should use an ArrayList of Strings to store this, and the user should be able to enter as many song...
Top-down design: Design a program called TeamGame to simulate a simple game of drafting players to...
Top-down design: Design a program called TeamGame to simulate a simple game of drafting players to teams. Rules of the game: • There are two teams: Team A and Team B. • There are 50 players, with numbers from 1 to 50. • Each team will get 10 of the players. The program should randomly select 10 players for each team. To accomplish this, you may select each player randomly, or you may shuffle the list of players before making...
Problem 1 Create a new project called Lab7 Create a class in that project called ListORama...
Problem 1 Create a new project called Lab7 Create a class in that project called ListORama Write a static method in that class called makeLists that takes no parameters and returns no value In makeLists, create an ArrayList object called avengers that can hold String objects. Problem 2 Add the following names to the avengers list, one at a time: Chris, Robert, Scarlett, Clark, Jeremy, Gwyneth, Mark Print the avengers object. You will notice that the contents are displayed in...
Step 1: Create a new Java project called Lab5.5. Step 2: Now create a new class...
Step 1: Create a new Java project called Lab5.5. Step 2: Now create a new class called aDLLNode. class aDLLNode { aDLLNode prev;    char data;    aDLLNode next; aDLLNode(char mydata) { // Constructor data = mydata; next = null;    prev = null;    } }; Step 3: In the main() function of the driver class (Lab5.5), instantiate an object of type aDLLNode and print the content of its class public static void main(String[] args) { System.out.println("-----------------------------------------");    System.out.println("--------Create...
1. Create a new Java project called L2 and a class named L2 2. Create a...
1. Create a new Java project called L2 and a class named L2 2. Create a second class called ArrayExaminer. 3. In the ArrayExaminer class declare the following instance variables: a. String named textFileName b. Array of 20 integers named numArray (Only do the 1st half of the declaration here: int [] numArray; ) c. Integer variable named largest d. Integer value named largestIndex 4. Add the following methods to this class: a. A constructor with one String parameter that...
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final...
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final grade for the course. Assume the following (you can hard-code these values in your program). Assignments are worth 30% Labs are worth 40% Mid-term is worth 15% Final is worth 15% Ask for the grades in each category. Store them in a double variable. Print out the final percentage grade.           For example, Final Grade Calculation Enter percentage grades in the following order. Assignments,...
Using NetBeans, create a Java project named FruitBasket. Set the project location to your own folder....
Using NetBeans, create a Java project named FruitBasket. Set the project location to your own folder. 3. Import Scanner and Stacks from the java.util package. 4. Create a Stack object named basket. 5. The output shall: 5.1.Ask the user to input the number of fruits s/he would like to catch. 5.2.Ask the user to choose a fruit to catch by pressing A for apple, O for orange, M for mango, or G for guava. 5.3.Display all the fruits that the...
in Java using netbeans create a project and in it a class with a main. We...
in Java using netbeans create a project and in it a class with a main. We will be using the Scanner class to read from the user. At the top of your main class, after the package statement, paste import java.util.Scanner; Part A ☑ In your main method, paste this code. Scanner scan = new Scanner(System.in); System.out.println("What is x?"); int x = scan.nextInt(); System.out.println("What is y?"); int y = scan.nextInt(); System.out.println("What is z?"); int z = scan.nextInt(); System.out.println("What is w?");...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT