use the input provided in the given list and execute the program. question2b COS
ID: 3706136 • Letter: U
Question
use the input provided in the given list and execute the program.
question2b
COS1511/102/1/2018 The sales tax paid is 10% The total cost per booking is-Rm00R53?? submit Submit a printout of the program and output. Question 2b Four experiments are performed, each consisting of five test results. The results for each experiment are given in the following list. Write a program using a nested loop to compute and display the average of the test results for each experiment. Display the average with a precision of two digits after the decimal point, 1st experiment results: 2nd experiment results: 3rd experiment results: 4th experiment results 16.9 25.4 34.8 45.2 27.9 36.8 33.4 19.4 16.8 10.2 20.8 18.9 : 36.9 39 49.2 45.1 42.7 23.2 31 27 Use the input provided in the given list and execute the program. submit Submit a printout of the program and output. Question 2c In this program, you have to make use of the switch statement. The average life expectancy (in hours) of a lightbulb based on the bulb's wattage is listed in the elow: Life expectancy (hours) Watts 25 40 25000 1000Explanation / Answer
// Here code is in c++ language
#include <iostream>
using namespace std;
int main(){
float a[4][5] = { //Here we have created a two dimentional array of rows =4 and column=5
{23.2, 31, 16.9, 27, 25.4} , //1st experiment result
{34.8, 45.2, 27.9, 36.8,33.4} , // 2ng experiment result
{19.4, 16.8, 10.2, 20.8, 18.9}, // 3rd experiment result
{36.9, 39, 49.2, 45.1, 42.7} //4th experiment result
};
for ( int i = 0; i < 4; i++ ){//loop for each experiment
float sum=0;//variable for calculate sum of each experiment result
for ( int j = 0; j < 5; j++ ) {//loop for each result of each experiment
//cout << a[i][j]<<" ";
sum+=a[i][j];//caculated sum
}
printf("average of %d experiment : %.2f ",i+1, sum/5); // sum/5 since average=sum/number of input
cout<<endl;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.