In: Computer Science
program runs but does not compute the average. Here is what I have. Thank you
#include <iostream>
#include<iomanip>
#include"Average.h"
using namespace std;
int main() {
cout<<"Enter 3 integers, seperated by spaces, on
a single line: ";
int number1, number2, number3;
cin>>number1>>number2>>number3;
int average;
double avg;
// average = computeAverage(number1, number2,
number3);
cout<<"Average of "<<number1<<" and
"<<number2 <<" and "<<number3 <<" is
"
<<average<<endl;
cout<<"Enter 2 integers, seperated by a space,
on a single line: ";
// int number1, number2;
cin>>number1>>number2;
cout<<"Average of "<<number1<<" and
"<<number2<<" is "
<<average<<endl;
cout<<"Enter 3 doubles, seperated by a space, on
a single line: ";
double num1, num2, num3;
cin>>num1>>num2>>num3;
cout<<"Average of " <<num1<<" and
"<<num2<<" and "<<num3<<" is "
<<average<<endl;
cout<<"Enter 2 doubles, seperated by a space, on
a single line: ";
// double num1, num2;
cin>>num1>>num2;
cout<<"Average of "<<num1<<" and
"<<num2<<" is "
<<average<<endl;
}
#include<iostream>
#include<iomanip>
class Average{
private:
int number1;
int number2;
int number3;
int average;
double num1;
double num2;
double num3;
double avg;
int computeAverage(int x, int y, int z){
int averageValue = (x + y + z)/3;
return averageValue;
}
int computeAverage(int x, int y){
int averageValue = (x + y)/2;
return averageValue;
}
double computeAverage(double x, double y, double
z){
double averageValue = (x + y +
z)/3;
return averageValue;
}
double computeAverage(double x, double y){
double averageValue = (x +
y)/2;
return averageValue;
}
};
#include <iostream>
#include<iomanip>
using namespace std;
class Average{
private:
int number1;
int number2;
int number3;
int average;
double num1;
double num2;
double num3;
double avg;
public:
int computeAverage(int x, int y, int z){
int averageValue = (x + y + z)/3;
return averageValue;
}
int computeAverage(int x, int y){
int averageValue = (x + y)/2;
return averageValue;
}
double computeAverage(double x, double y, double z){
double averageValue = (x + y + z)/3;
return averageValue;
}
double computeAverage(double x, double y){
double averageValue = (x + y)/2;
return averageValue;
}
};
int main() {
cout<<"Enter 3 integers, seperated by spaces, on a single line: ";
int number1, number2, number3;
cin>>number1>>number2>>number3;
Average a;
int average = a.computeAverage(number1,number2,number3);
double avg;
// average = computeAverage(number1, number2, number3);
cout<<"Average of "<<number1<<" and "<<number2 <<" and "<<number3 <<" is "
<<average<<endl;
cout<<"Enter 2 integers, seperated by a space, on a single line: ";
// int number1, number2;
cin>>number1>>number2;
average = a.computeAverage(number1,number2);
cout<<"Average of "<<number1<<" and "<<number2<<" is "
<<average<<endl;
cout<<"Enter 3 doubles, seperated by a space, on a single line: ";
double num1, num2, num3;
cin>>num1>>num2>>num3;
average = a.computeAverage(number1,number2,number3);
cout<<"Average of " <<num1<<" and "<<num2<<" and "<<num3<<" is "
<<average<<endl;
cout<<"Enter 2 doubles, seperated by a space, on a single line: ";
// double num1, num2;
cin>>num1>>num2;
average = a.computeAverage(number1,number2);
cout<<"Average of "<<num1<<" and "<<num2<<" is "
<<average<<endl;
}
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME