Question
Please Write in C++
(10-30) @ 11:55pm

1.9 HW7 This homework assignment gives you the opportunity to practice functions, functions that call other functions, refere
2. Hint for implementation To find the lowest of 5 values, you can implement the following pseudocode Let vali, val2, val3, v
Test-1 Codes output should match the following: Enter a judges score: 9.9 Enter a judges score: 7.0 Enter a judges score:
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <bits/stdc++.h>
using namespace std;
void calcSCore(double scores[], int n)
{
   double min=scores[0];
   double max=scores[0];
   double sum=0.0;
   for (int i = 0; i < n; ++i)
   {
       sum+=scores[i];
       if (max<scores[i])
       {
           max=scores[i];
       }
       if (min>scores[i])
       {
           min=scores[i];
       }
   }
   sum=sum-(min+max);
   cout<<"After dropping the lowest and highest score, average score is "<<sum/3<<endl;
   cout<<"Normal Termination exiting"<<endl;
}
void getJudgeData()
{
   double scores[5];
   for (int i = 0; i < 5; ++i)
   {
       cout<<"Enter a judge's score : ";
       cin>>scores[i];
       if (scores[i]<0||scores[i]>10)
       {
           cout<<"The score must be between 0.0 and 10.0, exiting"<<endl;
           exit(EXIT_FAILURE);
       }
   }
   calcSCore(scores,5);
}
int main(int argc, char const *argv[])
{
   getJudgeData();
   return 0;
}

With randomly generated values -

#include <bits/stdc++.h>
using namespace std;
double randomFunction(double start, double end)
{
double f = (double)rand() / RAND_MAX;
return start + f * (end - start);
}
void calcSCore(double scores[], int n)
{
   double min=scores[0];
   double max=scores[0];
   double sum=0.0;
   for (int i = 0; i < n; ++i)
   {
       sum+=scores[i];
       if (max<scores[i])
       {
           max=scores[i];
       }
       if (min>scores[i])
       {
           min=scores[i];
       }
   }
   sum=sum-(min+max);
   cout<<"After dropping the lowest and highest score, average score is "<<sum/3<<endl;
   cout<<"Normal Termination exiting"<<endl;
}
void getJudgeData()
{
   double scores[5];
   for (int i = 0; i < 5; ++i)
   {
       //cout<<"Enter a judge's score : ";
       //cin>>scores[i];
       scores[i]=randomFunction(0,10);
       cout<<"Judge's score is "<<scores[i]<<endl;
       if (scores[i]<0||scores[i]>10)
       {
           cout<<"The score must be between 0.0 and 10.0, exiting"<<endl;
           exit(EXIT_FAILURE);
       }
   }
   calcSCore(scores,5);
}
int main(int argc, char const *argv[])
{
   getJudgeData();
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Please Write in C++ (10-30) @ 11:55pm 1.9 HW7 This homework assignment gives you the opportunity...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions...

    ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions -Learn to use reference variables Coding Guidelines for All Labs/Assignments (You will be graded on this) -Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). -Keep identifiers to a reasonably short length. -Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables,...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • I need help with this c++ question please thank you ltls. The program should urt valte....

    I need help with this c++ question please thank you ltls. The program should urt valte. 11. Lowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getscore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of...

  • C++ please use only easy code and stdio.h because im just a beginner Description Write the...

    C++ please use only easy code and stdio.h because im just a beginner Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value...

  • In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a tes...

    In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...

  • Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview...

    Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview For this assignment, write a program that will calculate the quiz average for a student in the CSCI 240 course. The student's quiz information will be needed for later processing, so it will be stored in an array. For the assignment, declare one array that will hold a maximum of 12 integer elements (ie. the quiz scores). It is recommended that this program be...

  • ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will...

    ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...

  • C Programming QUESTION 9 Write a program that prompts for and reads four integer input values,...

    C Programming QUESTION 9 Write a program that prompts for and reads four integer input values, then a single character command. Submit your program as a .c file named midterm_prog2.c. Note that, similarly to your programming assignments, some percentage of your grade will depend on proper programming style. Your program will calculate and print a new value based on the command that's entered, as follows: 'A' or 'a': Calculate the average of the four input values 'S' or 's': Calculate...

  • c++ Instructions Overview In this programming challenge you will create a program to handle student test...

    c++ Instructions Overview In this programming challenge you will create a program to handle student test scores.  You will have three tasks to complete in this challenge. Instructions Task 1 Write a program that allocates an array large enough to hold 5 student test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT