Third year programming students have entered a hackathon competition and they are judged by two judges who gives them a score from 1 to 100. You are required to write a program that will help the organizers to tally their scores as well as to determine who the winner is.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int n;
int score1;
int score2;
int winnerStudent=0;
int winnerStudentScore=-1;
cout<<"Enter the number of students: ";
cin>>n;
for(int i=0;i<n;i++){
cout<<"\nEnter scores for student "<<(i+1)<<"\n\n";
do{
cout<<"Enter score of judge 1: ";
cin>>score1;
}while(score1<1 || score1>100);
do{
cout<<"Enter score of judge 2: ";
cin>>score2;
}while(score2<1 || score2>100);
int totalScore=score1+score2;
if(totalScore>winnerStudentScore){
winnerStudentScore=totalScore;
winnerStudent=i;
}
}
cout<<"\nThe student "<<(winnerStudent+1)<<" is the winner\n\n";
cin>>winnerStudentScore;
return 0;
}
Comments
Leave a comment