Code:
#include<stdio.h>
void rating_msg();
void rating( );
void lowest_rating();
void highest_rating();
void total_score();
void average_score();
int user_scores[5];
int total ;
int main(){
int user[5], cost, games, bCompat, resolution, sum, lowest, highest;
for(int i=0; i<3;i++){
printf("User %d\n", i+1);
rating_msg();// print msg function
printf("Cost>>\t");
scanf("%d",&cost);
if(cost>5){
printf("Invalid Rating! \nPlease Choose Again");
}
printf("\nGames>>\t");
scanf("%d", &games);
if(games>5){
printf("Invalid Rating! \nPlease Choose Again");
}
printf("\nBackward Compatibility>>\t");
scanf("%d", &bCompat);
if(bCompat>5){
printf("Invalid Rating! \nPlease Choose Again");
}
printf("\nScreen Resolution>>\t");
scanf("%d",&resolution);
if(resolution>5){
printf("Invalid Rating! \nPlease Choose Again");
}
user_scores[i] = cost+games+bCompat+resolution;
printf("\nTotal Score>> %d\n\n", user_scores[i]);
}
lowest_rating();
highest_rating();
total_score();
average_score();
}
void rating_msg(){
printf("Please Rate the PS5 console based on the following factors!\n");
printf("The Rating is between 1 and 5\n1 being the lowest rate\nand 5 being the highest.\n\n");
}
void highest_rating(){
int max= -1, mxPos= -1;
for(int i=0; i<3;i++){
if(user_scores[i] > max){
max= user_scores[i];
mxPos = i;
}
}
printf("\nHighest %d\n\n",user_scores[mxPos]);
}
void lowest_rating(){
int min= 999, mnPos= 999;
for(int i=0; i<3;i++){
if(user_scores[i] < min){
min= user_scores[i];
mnPos = i;
}
}
printf("\nLowest %d\n\n",user_scores[mnPos]);
}
void total_score(){
for( int i=0 ;i<3;i++){
printf("\n\nTotalScore User%d:%d",i+1,user_scores[i]);
total+=user_scores[i];
}//end of second for loop
printf("\n\nTotal:\t %d",total);
}
void average_score(){
float avg;
avg = total / 3;
printf("\n\nAverage Score:%0.2f",avg);
if ( avg > 16 && avg <= 20){
printf("\nAverage Rating--> Excellent");
}
else if ( avg > 10 && avg <= 15){
printf("\nAverage Rating--> Average");
}else {
printf("\nAverage Rating--> Poor");
}
}
I got some help from school. But can you type this in a shorter and easier to understand way