90 142
Assignments Done
99.4%
Successfully Done
In September 2020

# Answer to Question #4511 in C++ for david

Question #4511
Question 1: Write a program, that during the entering of real resistance values prints the average resistance value.
Use a function Average_resistance() , to compute the average resistance.

make a PSD before writting the program.
1
2012-04-03T11:17:48-0400
#include <iostream>

using namespace std;

double Average_resistance(){

int n = 0;

double sum = 0;

double val;

cout<<"Input real resistance values. Input -1 if you want to stop.
";

cin>>val;

while(val != -1){

n++;

sum += val;

cout<<"Current AV: "<< sum/n << endl;

cin>>val;

}

return sum/n;

}

int main(){

char input;

while(1){

cout<<"1 - count average resistance
";

cout<<"2 - exit
";

cin>>input;

if(input == '1'){

cout<<"---- Average value: "<<Average_resistance()<<" ----"<<endl;

} else if(input == '2'){

return 0;

} else {

cout<<"Wrong symbol! Try again
";

}

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!