I am having trouble having this c++ code run correctly. I need some assistance as I am now lost. Below I have inserted a snip of the results when I complie everything in GDN online. ( https://www.onlinegdb.com/edit/BlpBk7fqx ) main.cpp #include "ScoreStatistics.cpp" #include int main() { int ch=1; string names[100]; float scores[100]; int numberStudents=0; while(ch!=4){ cout<<"1. Enter the test scores via a user prompt\n"; cout<<"2. Display grade roster\n"; cout<<"3. Display statistics\n"; cout<<"4. Exit\n"; cout<<"Your choice: "; cin>>ch; if(ch==1){ numberStudents=enterTestScoresViaUserPrompt(names,scores); }else if(ch==2){ displayGradeRoster(scores,names,numberStudents); }else if(ch==3){ displayClassStatistics(scores,numberStudents); }else if(ch==4){   }else{ cout<<"Wrong menu item.\n\n"; } } return 0; }     ScoreStatistics.cpp #include "functions.hpp" #include   char getGrade(float score){ if(score>=90 && score<=100){ return 'A'; } if(score>=80 && score<=89){ return 'B'; } if(score>=70 && score<=79){ return 'C'; } if(score>=60 && score<=69){ return 'D'; } return 'F'; } float computeMaxScore(float scores[],int numberStudents){ float maximumTestScore=scores[0]; for(int i=0;iscores[i]){ minimumTestScore=scores[i]; } } return minimumTestScore; } float computeAvgScore(float scores[],int numberStudents){ float totalScore=0; for(int i=0;i>numberStudents; if(numberStudents<=0){ cout<<"\nInvalid value, please enter a correct value\n\n"; } } for(int i=0;i>names[i]; scores[i]=-1; while(scores[i]<0){ cout<<"Enter the score of the student "<<(i+1)<<": "; cin>>scores[i]; if(scores[i]<=0){ cout<<"\nInvalid value, please enter a correct value\n\n"; } } } return numberStudents; } void displayGradeRoster(float scores[],string names[],int numberStudents){ cout<<"\n"; cout< #include #include #include using namespace std;   char getGrade(float score); float computeMaxScore(float scores[],int numberStudents); float computeMinScore(float scores[],int numberStudents); float computeAvgScore(float scores[],int numberStudents); int enterTestScoresViaUserPrompt(string names[],float scores[]); void displayGradeRoster(float scores[],string names[],int numberStudents); void displayClassStatistics(float scores[],int numberStudents);

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

I am having trouble having this c++ code run correctly. I need some assistance as I am now lost. Below I have inserted a snip of the results when I complie everything in GDN online.

( https://www.onlinegdb.com/edit/BlpBk7fqx )

main.cpp

#include "ScoreStatistics.cpp"
#include <iostream>
int main() {
int ch=1;
string names[100];
float scores[100];
int numberStudents=0;
while(ch!=4){
cout<<"1. Enter the test scores via a user prompt\n";
cout<<"2. Display grade roster\n";
cout<<"3. Display statistics\n";
cout<<"4. Exit\n";
cout<<"Your choice: ";
cin>>ch;
if(ch==1){
numberStudents=enterTestScoresViaUserPrompt(names,scores);
}else if(ch==2){
displayGradeRoster(scores,names,numberStudents);
}else if(ch==3){
displayClassStatistics(scores,numberStudents);
}else if(ch==4){
 
}else{
cout<<"Wrong menu item.\n\n";
}
}
return 0;
}

 

 

ScoreStatistics.cpp

#include "functions.hpp"
#include <iostream>
 
char getGrade(float score){
if(score>=90 && score<=100){
return 'A';
}
if(score>=80 && score<=89){
return 'B';
}
if(score>=70 && score<=79){
return 'C';
}
if(score>=60 && score<=69){
return 'D';
}
return 'F';
}
float computeMaxScore(float scores[],int numberStudents){
float maximumTestScore=scores[0];
for(int i=0;i<numberStudents;i++){
if(maximumTestScore<scores[i])
maximumTestScore=scores[i];
}
return maximumTestScore;

    float computeMinScore(float scores[],int numberStudents){
    float minimumTestScore=scores[0];
for(int i=0;i<numberStudents;i++){
if(minimumTestScore>scores[i]){
minimumTestScore=scores[i];
}
}
return minimumTestScore;
}
float computeAvgScore(float scores[],int numberStudents){
float totalScore=0;
for(int i=0;i<numberStudents;i++){
totalScore+=scores[i];
}
float classAverageScore=totalScore/(float)numberStudents;
return classAverageScore;
}


int enterTestScoresViaUserPrompt(string names[],float scores[]){
int numberStudents=-1;
while(numberStudents<=0){
cout<<"Enter the number of students: ";
cin>>numberStudents;
if(numberStudents<=0){
cout<<"\nInvalid value, please enter a correct value\n\n";
}
}
for(int i=0;i<numberStudents;i++){
cout<<"Enter the name of the student "<<(i+1)<<": ";
cin>>names[i];
scores[i]=-1;
while(scores[i]<0){
cout<<"Enter the score of the student "<<(i+1)<<": ";
cin>>scores[i];
if(scores[i]<=0){
cout<<"\nInvalid value, please enter a correct value\n\n";
}
}
}
return numberStudents;
}

void displayGradeRoster(float scores[],string names[],int numberStudents){
cout<<"\n";
cout<<fixed<<left<<setw(15)<<"Name"<<setw(15)<<"Test Score"<<"Grade\n";
cout<<left<<setw(15)<<"===="<<setw(15)<<"=========="<<"=====\n";
for(int i=0;i<numberStudents;i++){
cout<<left<<setw(15)<<names[i]<<setprecision(0)<<setw(15)<<scores[i]<<getGrade(scores[i])<<"\n";
}
cout<<"\n";
}

void displayClassStatistics(float scores[],int numberStudents){
cout<<"\n";
for(int i=0;i<15;i++){
cout<<"=";
}
cout<<"Class Statistics";
for(int i=0;i<15;i++){
cout<<"=";
}
float maximumTestScore=computeMaxScore(scores, numberStudents);
float minimumTestScore=computeMinScore(scores, numberStudents);
float classAverageScore=computeAvgScore(scores, numberStudents);
 
cout<<"\nNumber of students in the class: "<<numberStudents<<"\n";
cout<<"Class Average score: "<<setprecision(4)<<classAverageScore<<"\n";
cout<<"Maximum Test score: "<<setprecision(0)<<maximumTestScore<<"\n";
cout<<"Minimum Test score: "<<minimumTestScore<<"\n\n";
}

function.hpp

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
 
char getGrade(float score);
float computeMaxScore(float scores[],int numberStudents);
float computeMinScore(float scores[],int numberStudents);
float computeAvgScore(float scores[],int numberStudents);
int enterTestScoresViaUserPrompt(string names[],float scores[]);
void displayGradeRoster(float scores[],string names[],int numberStudents);
void displayClassStatistics(float scores[],int numberStudents);

 

Run
O Debug
1 Stop
C Share
A Save
{} Beautify
Language C++
main.cpp
ScoreStatistics.cpp : functions.hpp !
1 #include "ScoreStatistics.cpp"
2 #include <iostream>
3- int main() {
4 int ch=1;
5 string names[100];
6 float scores[100];
7 int numberStudents=0;
8 - while(ch!=4){_
input
stderr
Compilation failed due to following error(s).
ScoreStatistics.cpp:(.text+0x0): multiple definition of `getGrade(float)'; /tmp/cc73vNAV.o:main.cpp:( .text+0x0): first defined here
/usr/bin/ld: /tmp/CCU590AV.o: in function `computeMaxScore(float*, int)':
ScoreStatistics.cpp:(.text+0xa0): multiple definition of `computeMaxScore(float*, int)'; /tmp/cc73vNAV.o:main.cpp:(.text+0xa0): first defined here
/usr/bin/ld: /tmp/CCU590AV.o: in function `computeMinScore(float*, int)':
ScoreStatistics.cpp:(.text+0x113): multiple definition of `computeMinScore(float*, int)'; /tmp/cc73vNAV.o:main.cpp:(.text+0x113): first defined here
/usr/bin/ld: /tmp/CCU590AV.o: in function `computeAvgScore(float*, int)':
ScoreStatistics.cpp:(.text+0x18a): multiple definition of `computeAvgScore(float*, int)'; / tmp/cc73vNAV.o:main.cpp:(.text+0x18a): first defined here
/usr/bin/ld: /tmp/CCU590AV.o: in function `enterTestScoresViaUserPrompt(std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, float*)':
ScoreStatistics.cpp:(.text+0x1f7): multiple definition of `enterTestScoresViaUserPrompt(std::_cxx11::basic_string, std::allocator >*, float*)'; /tmp/CC73VNAV.o:main.
/usr/bin/ld: /tmp/CCU590AV.o: in function `displayGradeRoster(float*, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, int)':
ScoreStatistics.cpp:(.text+0x3cc): multiple definition of `displayGradeRoster (float*, std: :_cxx11::basic_string, std::allocator >*, int)'; /tmp/cc73vNAV.o: main.cpp:(
/usr/bin/ld: /tmp/CCU590AV.o: in function `displayClassStatistics (float*, int)':
ScoreStatistics.cpp:(.text+0x5f5): multiple definition of `displayClassStatistics(float*, int)'; /tmp/CC73VNAV.o:main.cpp:(.text+0x5f5): first defined here
collect2: error: ld returned 1 exit status
Transcribed Image Text:Run O Debug 1 Stop C Share A Save {} Beautify Language C++ main.cpp ScoreStatistics.cpp : functions.hpp ! 1 #include "ScoreStatistics.cpp" 2 #include <iostream> 3- int main() { 4 int ch=1; 5 string names[100]; 6 float scores[100]; 7 int numberStudents=0; 8 - while(ch!=4){_ input stderr Compilation failed due to following error(s). ScoreStatistics.cpp:(.text+0x0): multiple definition of `getGrade(float)'; /tmp/cc73vNAV.o:main.cpp:( .text+0x0): first defined here /usr/bin/ld: /tmp/CCU590AV.o: in function `computeMaxScore(float*, int)': ScoreStatistics.cpp:(.text+0xa0): multiple definition of `computeMaxScore(float*, int)'; /tmp/cc73vNAV.o:main.cpp:(.text+0xa0): first defined here /usr/bin/ld: /tmp/CCU590AV.o: in function `computeMinScore(float*, int)': ScoreStatistics.cpp:(.text+0x113): multiple definition of `computeMinScore(float*, int)'; /tmp/cc73vNAV.o:main.cpp:(.text+0x113): first defined here /usr/bin/ld: /tmp/CCU590AV.o: in function `computeAvgScore(float*, int)': ScoreStatistics.cpp:(.text+0x18a): multiple definition of `computeAvgScore(float*, int)'; / tmp/cc73vNAV.o:main.cpp:(.text+0x18a): first defined here /usr/bin/ld: /tmp/CCU590AV.o: in function `enterTestScoresViaUserPrompt(std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, float*)': ScoreStatistics.cpp:(.text+0x1f7): multiple definition of `enterTestScoresViaUserPrompt(std::_cxx11::basic_string, std::allocator >*, float*)'; /tmp/CC73VNAV.o:main. /usr/bin/ld: /tmp/CCU590AV.o: in function `displayGradeRoster(float*, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, int)': ScoreStatistics.cpp:(.text+0x3cc): multiple definition of `displayGradeRoster (float*, std: :_cxx11::basic_string, std::allocator >*, int)'; /tmp/cc73vNAV.o: main.cpp:( /usr/bin/ld: /tmp/CCU590AV.o: in function `displayClassStatistics (float*, int)': ScoreStatistics.cpp:(.text+0x5f5): multiple definition of `displayClassStatistics(float*, int)'; /tmp/CC73VNAV.o:main.cpp:(.text+0x5f5): first defined here collect2: error: ld returned 1 exit status
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY