Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i have a classroom grading management application that i made in JAVA. i set two arrays ( students, grades) and populated them with data already.

i have a classroom grading management application that i made in JAVA.

i set two arrays ( students, grades) and populated them with data already.

i built a menu that gives you option to type in so you can see the information.

with JOptionPane you input...

"a" to see the average of the grades

"v" to show student names and grades

"e" to enter a new grade for student

"q" to quit

i cannot figure out how to program the "e" i need to ask the user for the index position of the grade they wish to change using JOptionPane. Then i need to obtain a new grade from the users input and change the value of the index postion that the user specified.

example [ 98, 76, 88, 65, 92]

JOptionPane.showInputDialog( "Please enter the index position of the grade you wish to change");

if user inputs "2", then it should target the "88"

JOptionPane.showInputDialog( "please enter new grade");

if user puts in "83" it should replace that "88" with the new number grade.

public class project2 {

public static void main(String[] args) { String[] students = {"Bob", "Joe", "Paul", "Amanda", "Chris"}; int[] grades = {98, 76, 88, 65, 92}; String menuchoice = showMenu(); while (menuchoice.equalsIgnoreCase("q") == false ){ if(menuchoice.equalsIgnoreCase("a") == true) { int sum = 0; for( int i = 0; i < grades.length; i++) { sum += grades[i]; }//ends for loop double avg = sum / grades.length; JOptionPane.showMessageDialog(null, "Average of all 5 grades is: " + " " + avg); }// ends if statement else if(menuchoice.equalsIgnoreCase("v") == true) { String displayinfo = "Students names and grades "; for(int i =0; i < grades.length; i++ ) { displayinfo += students[i] + " -> " + grades[i] + " "; }//ends for loop JOptionPane.showMessageDialog(null, displayinfo ); }// ends 1st else if else if(menuchoice.equalsIgnoreCase("e") == true) { // ask user to input index position of the number they want to change [0, 1, 2, 3, 4] JOptionPane.showInputDialog("Please enter the index position of the grade you wish to change "); //obtain a new grade JOptionPane.showInputDialog("Please enter new grade "); //show new array

}//ends 2nd else if menuchoice = showMenu(); }//ends while loop "q" }// end main //show Menu Method first public static String showMenu() { String msg = "Please select a menu option "; msg += "(v)iew all students grades "; msg += "(a)verage of all grades "; msg += "(e)nter new grade for student "; msg += "(q)uit program "; return JOptionPane.showInputDialog( msg ); }//ends showMenu

}// end class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

Are my points each supported by at least two subpoints?

Answered: 1 week ago