Question

Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and...

Java Programing Code only

Ragged Array Assignment

Outcome:

  • Student will demonstrate the ability to create and use a 2D array
  • Student will demonstrate the ability to create and use a jagged array
  • Student will demonstrate the ability to design a menu system
  • Student will demonstrate the ability to think

Program Specifications:

Write a program that does the following:

  1. Uses a menu system
  2. Creates an array with less than 25 rows and greater than 5 rows and an unknown number of columns
  3. You can assume that the row index represents one individual student
  4. Each column represents an exam score for that individual student (the number of exams will vary by student)
  5. Enter at least 10 students along with a varying number of exam scores for each different student.
  6. Display the Average for all exams by each Student Id
  7. Display the Average for each exam by Exam Number
  8. Display the class average
  9. Everything needs to be a written in Static Method

The menu system will have an option to input grades for the next student. Once pressed the user will then enter how many exams that student has taken. The program will then ask the user to enter each of those exam scores.

Menu will have an option to display the exam average by student.

Menu will have an option to display the exam average by exam.

Menu will have an option to display the current class average for all exams.

Submission Requirements:

  • You must follow the rules from the second assignment.

YOU CANNOT:

  • Use global variables
  • Use the word goto
  • Use the break command outside a case statement
0 0
Add a comment Improve this question Transcribed image text
Answer #1

please do upvote .If you have any problem do comment and i shall be happy to help you.Thanks for using HomeworkLib.

-------------------------

import java.util.Arrays;
import java.util.Scanner;

public class Menu
{
  
   public static void main(String args[])
   {
      
       //variables
       int maxNumberOfStudents=15;
       int countOfStudents=0;
       int highestCol=0;
      
       double sum=0;
       double avg=0;
       double count=0;
       Scanner read=new Scanner(System.in);
      
      
      
       //jagged array
       int examScores[][] = new int[maxNumberOfStudents][];
       int choice=0;
      
       //keep asking until choice=5
   while(choice!=5)
   {
       printMenu();
      
       System.out.println("Enter choice: ");
       choice=read.nextInt();
      
       switch(choice)
       {
      
       //get details
       case 1:
      
           System.out.println("Enter number of exams given by student: ");
int cols=read.nextInt();
          
if(cols>highestCol)
{
   highestCol=cols;
}
  
examScores[countOfStudents]= new int[cols];
  
for(int c=0;c<cols;c++)
{
  
   System.out.println(String.format("Enter score for exam %d :",c+1));
  
   examScores[countOfStudents][c]=read.nextInt();
}
          
           countOfStudents++;

           break;
          
          
       case 2:
          
           //calculate average by students and display it
          
           System.out.println("Enter student id: ");
       int id=read.nextInt();
               int i=id-1;
              
               count=0;
               sum=0;
               for(int c=0;c<examScores[i].length;c++)
               {
                  
                   sum=sum+examScores[i][c];
                  
                  
               }
              
               avg=sum/examScores[i].length;
              
              
               System.out.println(String.format("average of student %d is %f",id,avg));
          
          
          
           break;
          
          
       case 3:
          
          
          
           System.out.println("Enter exam number: ");
       int number=read.nextInt();
           int examIndex=number-1;
               count=0;
               sum=0;
               for(int r=0;r<countOfStudents;r++)
               {
                  
                   try
                   {
                       sum=sum+examScores[r][examIndex];
                       count++;
                      
                      
                   }
                   //catch index out of bounds exception when student r not have scores for exam c
                   catch(Exception e)
                   {
                      
                   }
              
              
               }
               avg=sum/count;
              
               System.out.println(String.format("average of exam no %d is %f",number,avg));
          
           break;
          
          
       case 4:
          

           for(int c=0;c<highestCol;c++)
           {
               count=0;
               sum=0;
               for(int r=0;r<countOfStudents;r++)
               {
                  
                   try
                   {
                       sum=sum+examScores[r][c];
                       count++;
                      
                      
                   }
                   //catch index out of bounds exception when student r not have scores for exam c
                   catch(Exception e)
                   {
                      
                   }
               }
              
              
               avg=sum/count;
              
               System.out.println(String.format("average of exam no %d is %f",c+1,avg));
           }
           break;
          
          
       }
   }
   }

   private static void printMenu() {
       // TODO Auto-generated method stub
       System.out.println("1. input grades for next student");
       System.out.println("2. display the exam average by student.");
       System.out.println("3. display the exam average by exam.");
       System.out.println("4. display the current class average for all exams.");
       System.out.println("5. quit");

      
   }
  
}

----------------------

Add a comment
Know the answer?
Add Answer to:
Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and...
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
  • ***************C PROGRAMMING ONLY************* Demonstrate the ability to create an array on the stack Demonstrate the ability...

    ***************C PROGRAMMING ONLY************* Demonstrate the ability to create an array on the stack Demonstrate the ability to create an array on the heap allowing user to choose the number of values to store. Demonstrate the ability to store an array of Struct values on both the stack and the heap. Program Specifications: 1. Create a struct with at least 3 fields - any struct you want but explain it in your comments in the code. Populate at least 10 elements...

  • Methods and File Output and Exceptions Outcome: Student will demonstrate the ability to write, use and...

    Methods and File Output and Exceptions Outcome: Student will demonstrate the ability to write, use and call methods Student will demonstrate the ability to pass values to and from methods Student will demonstrate the ability to catch exceptions Student will demonstrate the ability to create a text file Student will demonstrate the ability to validate input data Program Specifications: You to write a menu driven program. The program will use a switch statement. The cases will be as follows: Get...

  • *MUST BE IN C PROGRAMMING* Demonstrate the ability to think critically Demonstrate the ability to work...

    *MUST BE IN C PROGRAMMING* Demonstrate the ability to think critically Demonstrate the ability to work with strings and chars Demonstrate the ability to design a menu system Write a simple program that allows the user to enter a number between 1 and 1000.  The program will then display the Roman numeral equivalent.  Allow the user to keep entering numbers for conversion to Roman numerals, or to quit, using a menu system of your own design. Submission Requirements: You are to write...

  • 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...

  • The purpose of this assignment is to get experience with an array, do while loop and...

    The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...

  • Need code written for a java eclipse program that will follow the skeleton code. Exams and...

    Need code written for a java eclipse program that will follow the skeleton code. Exams and assignments are weighted You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...

  • Please write a Java program that does the following: Create an array of 100 integers. Store...

    Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...

  • Using the following parallel array and array of vectors: // may be declared outside the main...

    Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS =3; // may only be declared within the main function string Students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Write a C++ program to run a menu-driven program with the following choices: 1) Display the grades 2) Add grade 3) Remove grade for all students for a selected assignment 4) Display Average for each student 5) Display the name of...

  • Using Java In this assignment we are working with arrays. You have to ask the user...

    Using Java In this assignment we are working with arrays. You have to ask the user to enter the size of the integer array to be declared and then initialize this array randomly. Then use a menu to select from the following Modify the elements of the array. At any point in the program, if you select this option you are modifying the elements of the array randomly. Print the items in the array, one to a line with their...

  • (JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students...

    (JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below. Then, write methods for: Computing the...

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