Manipulate multiple arrays, of different types using loops. The program will build a small database of student
Question:
Manipulate multiple arrays, of different types using loops. The program will build a small database of student names and marks, then print the average mark, the student with the highest mark, and the student with the lowest mark. In order:
1. The program will prompt the user with "How many students are there? ", then read in a positive integer n (you don't have to deal with bad input, but you do have to remember what to do with the newline generated by the user input).
2. The program will then read in n student names and marks with prompts "Enter name of student i: " and "Enter mark i: ", where i is replaced by a number from 1 to n, in order. Again, remember that user input generates newlines in the input stream you have to deal with.
3. The program will then print "The average mark is: " and print the average mark together on their own line.
4. The program will then print "The best student is " and print the student's name together on their own line.
5. The program will then print "The worst student is " and print the student's name together on their own line.
Prompts do not need a newline - that will come from the data entry by the user.
The best and worst student are determined by the highest and lowest mark respectively. The best and worst mark will be unique.
An example with both input and output would be:
Enter name of student 1: Luke
Enter mark 1: 50
Enter name of student 2: Cat
Enter mark 2: 99
Enter name of student 3: Nick
Enter mark 3: 98
Enter name of student 4: Mazza
Enter mark 4: 98
The average mark is: 86.25
The best student is Cat
The worst student is Luke
Transportation A Global Supply Chain Perspective
ISBN: 9781337406642
9th Edition
Authors: Robert A. Novack, Brian Gibson, Yoshinori Suzuki, John J. Coyle