(Statistics) a. Write a C++
b. Extend the program written for Exercise 1a to display each grade and its letter equivalent, using the following scale:
(a)
Program Plan:
- Declaremax and count variables of int data type.
- Declare sumand average variables of double data type
- Declare an array grade[100] of double data type.
- Use for loop to read all the array elements from the user.
- Use if statementto check the negative value.
- Calculatethe sum and average of all the user entered score.
- Display the calculated results to the user.
- Use for loop to calculate grades below the average.
- Use if condition to find the grades below the average.
- Display the grades below average by using the asterisk in the front of the grade(*).
- int main() method function is used to perform all the tasks.
Program Description: The main purpose of the program is to read all scores from the user, storing the scores in the grade[] array, calculating the sum and average of all the entered elements and to display the grades below average by using the asterisk in the front of grade(*).
Explanation of Solution
Program code:
//including required header files #include<iostream> usingnamespacestd; //main method int main() { //declaring required variables int max = 100, count =0; double sum=0, average=0; //Declaring the array to store value of grades double grade[max]; cout<<"Enter scores and any negative number to terminate"<<endl; //This loop will execute maximum of 100 //while loop while(count<max){ //Reading inputs from user cin>>grade[count]; //if the number is negative then loop is terminated if(grade[count]<0) break; //adding the entered sum sum = sum + grade[count]; //increnting loop variable count++; }//end of while loop //Calculating average average = sum/count; //displaying Calculated results to the user cout<<"Total of the scores: "<<sum<<endl; cout<<"Average of the scores: "<<average<<endl; cout<<"Scores below average: "; //for loop to find the score below average for(int i=0; i<count; i++) { //if the score is below average if(grade[i]<average) { cout<<"\n * "<<grade[i]; } } return0; }//end of the main method
Sample output:
(b)
Program Plan:
- Declaremax and count variables of int data type.
- Declare sumand average variables of double data type
- Declare an array grade[100] of double data type.
- Use for loop to read all the array elements from the user.
- Use if statement to check the negative value.
- Calculate the sum and average of all the user entered score.
- Display the calculated results to the user.
- Use for loop to calculate grades below the average.
- Use if condition to find the grades below the average.
- Display the grades below average by using the asterisk in the front of grade(*).
- Use if condition to find the grade.
- int main() method function is used to perform all the task.
Program Description: The main purpose of the program is to modify the program code given in part (a) so that the code will also display the grade letters to the user.
Explanation of Solution
Program code:
//including required header files #include<iostream> usingnamespacestd; //main method int main() { //declaring required variables int max = 100, count =0; double sum=0, average=0; //Declaring the array to store value of grades double grade[max]; cout<<"Enter scores and any negative number to terminate"<<endl; //This loop will execute maximum of 100 //while loop while(count<max){ //Reading inputs from user cin>>grade[count]; //if the number is negative then loop is terminated if(grade[count]<0) break; //adding the entered sum sum = sum + grade[count]; //increnting loop variable count++; }//end of while loop //Calculating average average = sum/count; //displaying Calculated results to the user cout<<"Total of the scores: "<<sum<<endl; cout<<"Average of the scores: "<<average<<endl; cout<<"Scores below average: "; //for loop to find the score below average for(int i=0; i<count; i++) { //if the score is below average if(grade[i]<average) { cout<<"\n * "<<grade[i]; } } //displaying message to the user cout<<"\n Grades and equivalent letters are: "; //for loop for(int i=0; i<count; i++) { //if grades are between 90 and 100 if(grade[i]<=100&& grade[i]>=90){ cout<<" \n"<<grade[i]<<": A"<<endl; } /*if grades are greater than or equal to 80 and less than 90*/ elseif(grade[i]<90&& grade[i]>=80){ cout<<" \n"<<grade[i]<<": B"<<endl; } /*if grades are greater than or equal to 70 and less than 80*/ elseif(grade[i]<80&& grade[i]>=70){ cout<<" \n"<<grade[i]<<": C"<<endl; } /*if grades are greater than or equal to 60 and less than 70*/ elseif(grade[i]<70&& grade[i]>=60) { cout<<" \n"<<grade[i]<<": D"<<endl; } //otherwise else{ cout<<" \n"<<grade[i]<<": F"<<endl; } } return0; }//end of the main method
Sample output:
Want to see more full solutions like this?
Chapter 7 Solutions
C++ for Engineers and Scientists
- You are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forward(A) A cellular system has 12 microcells with 10 channels per cell. The microcells are split into 3 microcells, and each microcell is further split into 4 picocells. Determine the number of channels available in system after splitting into picocelles.arrow_forwardQuestion 8 (10 points) Produce a relational schema diagram that corresponds to the following ER diagram for a Vacation Property Rentals database. Your relational schema diagram should include primary & foreign keys. Upload your relational schema diagram as a PDF document. Don't forget that the relation schemas for "Beach Property" and "Mountain Property" should each have primary keys. FYI: "d" in this notation denotes a subclass. Figure 2: ER Diagram for Question 8 id first RENTER name middle last address phone email 1 signs N id begin date RENTAL AGREEMENT end date amount N street address books city id 1 state address num. rooms PROPERTY zip code base rate type propertyType blocks to beach activity "B" "M" BEACH PROPERTY MOUNTAIN PROPERTYarrow_forward
- Notes: 1) Answer All Question, 2) 25 points for each question QI Figurel shows the creation of the Frequency Reuse Pattern Using the Cluster Size K: (A) illustrates how i and j can be used to locate a co-channel cell. huster 3 Cluster Cluster 2 X=7(i=2,j1)arrow_forwardYou are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following taking the database offline is not allowed since people are connected to it and how personal data might be bridged and not secured.Provide three references with you answer.arrow_forwardYou are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forward
- You are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answer from websitesarrow_forwardModern life has been impacted immensely by computers. Computers have penetrated every aspect of oursociety, either for better or for worse. From supermarket scanners calculating our shopping transactionswhile keeping store inventory; robots that handle highly specialized tasks or even simple human tasks,computers do much more than just computing. But where did all this technology come from and whereis it heading? Does the future look promising or should we worry about computers taking over theworld? Or are they just a necessary evil? Provide three references with your answer.arrow_forwardObjective: 1. Implement a custom Vector class in C++ that manages dynamic memory efficiently. 2. Demonstrate an understanding of the Big Five by managing deep copies, move semantics, and resource cleanup. 3. Explore the performance trade-offs between heap and stack allocation. Task Description: Part 1: Custom Vector Implementation 1. Create a Vector class that manages a dynamically allocated array. 。 Member Variables: ° T✶ data; // Dynamically allocated array for storage. std::size_t size; // Number of elements currently in the vector. std::size_t capacity; // Maximum number of elements before reallocation is required. 2. Implement the following core member functions: Default Constructor: Initialize an empty vector with no allocated storage. 。 Destructor: Free any dynamically allocated memory. 。 Copy Constructor: Perform a deep copy of the data array. 。 Copy Assignment Operator: Free existing resources and perform a deep copy. Move Constructor: Transfer ownership of the data array…arrow_forward
- 2.68♦♦ Write code for a function with the following prototype: * Mask with least signficant n bits set to 1 * Examples: n = 6 -> 0x3F, n = 17-> 0x1FFFF * Assume 1 <= n <= w int lower_one_mask (int n); Your function should follow the bit-level integer coding rules Be careful of the case n = W.arrow_forwardHi-Volt Components You are the IT manager at Hi-Voltage Components, a medium-sized firm that makes specialized circuit boards. Hi-Voltage's largest customer, Green Industries, recently installed a computerized purchasing sys- tem. If Hi-Voltage connects to the purchasing system, Green Industries will be able to submit purchase orders electronically. Although Hi-Voltage has a computerized accounting system, that system is not capable of handling EDI. Tasks 1. What options does Hi-Voltage have for developing a system to connect with Green Industries' pur- chasing system? 2. What terms or concepts describe the proposed computer-to-computer relationship between Hi-Voltage and Green Industries? why not? 3. Would Hi-Voltage's proposed new system be a transaction processing system? Why or 4. Before Hi-Voltage makes a final decision, should the company consider an ERP system? Why or why not?arrow_forwardConsider the following expression in C: a/b > 0 && b/a > 0.What will be the result of evaluating this expression when a is zero? What will be the result when b is zero? Would it make sense to try to design a language in which this expression is guaranteed to evaluate to false when either a or b (but not both) is zero? Explain your answerarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage