Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can anyone tell me what i am doing wrong? why isn't my output matching the example output? In this program you are going to save

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

can anyone tell me what i am doing wrong? why isn't my output matching the example output?

In this program you are going to save the names of 5 students and their course grades in parallel arrays. Your program should output the contents of both arrays, find the student with the highest score, and output the student name with the highest score along with his/her score. - Create an array of strings of size 5 called studentName [ ] and a parallel array of integers called studentGrade [] . - Initialize studentName [] with an initialization list using the following names: Amanda Baynes, Victor Hughes, Scott Collins, Lori Macbeth, and Manny Lopez (see Pr7-4.cpp for an example) - Read in the the grade of each student into the studentGrade [ ] array (see Pr7-15.cpp for an example). - In a for loop, print the name of each student left justified in a field width of 15 , along with his/her grade right justified in a field width of 3. - Determine the highest score achieved by a student. Display the student's name and the score. Also display the index of the student who made the highest score. I will be grading this lab with a script. If you do not use parallel arrays and do not find and use the index of the person with the highest score, you will NOT receive credit. I will change your grade in Blackboard to reflect this. Hints: - Check slide 3 of CS1336_Lect7c_Arrays_Compare_Parallel.pptx for the code to find the highest. - To display the name of the student who achieved the highest score, you will have to keep track of the index at which you found the highest grade. Output the student name corresponding to the index. For example, if studentGrade [2] is the highest grade, you will output studentName [2] as the corresponding student name. Sample studentName array declaration and example of how it appears in memory: Sample studentName array declaration and example of how it appears in memory: stringstudentName[]={"AmandaBaynes","VictorHughes","ScottCollins","LoriMacbeth","MannyLopez"}; When the input is as shown in Figure 1, your program should produce the output as shown in Figure 2. Figure 1: (sample input) 83729110098 Figure 2: (sample output) \begin{tabular}{lr} \hline Amanda Baynes & 83 \\ Victor Hughes & 72 \\ Scott Collins & 91 \\ Lori Macbeth & 100 \\ Manny Lopez & 98 \end{tabular} The highest score was 100 and was obtained by Lori Macbeth. The index of the student with the highest score is 3. \#include \#include \#include using namespace std; int main( ) I/ variables const int SIZE =5; int studentGrade[SIZE]; string studentName [ ] = \{ "Amanda Baynes", "Victor Hughes", "Scott Collins", "Lori Macbeth", "Manny Lop int highestGrade, index0fHighest; II for loop for (int i=0;i

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Explain clearly why electric field lines can never cross.

Answered: 1 week ago

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago