Question

In: Computer Science

program runs but does not compute the average. Here is what I have. Thank you #include...

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;
}
};

Solutions

Expert Solution

#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


Related Solutions

what am I doing wrong here? thank you! #include <iostream> #include <string> using namespace std; class...
what am I doing wrong here? thank you! #include <iostream> #include <string> using namespace std; class DivSales { private:    int quarterSales[4];    static double totalSales; public:    void add(int, int, int, int);    int sales(int);    static double getValue()    {        return totalSales;    };    void DivSales::add(int s1, int s2, int s3, int s4)    {        quarterSales[0] = s1;        quarterSales[1] = s2;        quarterSales[2] = s3;        quarterSales[3] = s4;...
I think I have this figured out, but need a double check... Thank you Here is...
I think I have this figured out, but need a double check... Thank you Here is the question: Regional distributors are currently using continuous review inventory policy. Compute and describe their inventory management policy and associated cost. Ignore inbound and outbound transportation cost. Provide answers and calculations for order quantity, demand during lead time, safety stock, average inventory level, inventory holding cost per week, ordering cost per week, and total cost per week. The service level is 90% and the...
Please in C++ thank you! Please also include the screenshot of the output. I have included...
Please in C++ thank you! Please also include the screenshot of the output. I have included everything that's needed for this. Pls and thank you! Write a simple class and use it in a vector. Begin by writing a Student class. The public section has the following methods: Student::Student() Constructor. Initializes all data elements: name to empty string(s), numeric variables to 0. bool Student::ReadData(istream& in) Data input. The istream should already be open. Reads the following data, in this order:...
PLEASE COMMENT THE FOLLOWING LEXICAL ANALYSER PROGRAM. Thank you. #include #include #include #include #include using namespace...
PLEASE COMMENT THE FOLLOWING LEXICAL ANALYSER PROGRAM. Thank you. #include #include #include #include #include using namespace std; int isKeyword(char buffer[]){ char keywords[32][10] = {"auto","break","case","char","const","continue","default", "do","double","else","enum","extern","float","for","goto", "if","int","long","register","return","short","signed", "sizeof","static","struct","switch","typedef","union", "unsigned","void","volatile","while"}; int i, flag = 0; for(i = 0; i < 32; ++i){ if(strcmp(keywords[i], buffer) == 0){ flag = 1; break; } } return flag; } int main(){ char ch, buffer[15], operators[] = "+-*/%="; ifstream fin("Text.txt"); int i,j=0; if(!fin.is_open()){ cout<<"error while opening the file\n"; exit(0); } while(!fin.eof()){ ch = fin.get();    for(i =...
The program runs but the math is not correct ( output for amount ) #include <iostream>...
The program runs but the math is not correct ( output for amount ) #include <iostream> using namespace std; int main() { int hoursParked; double total; double Car = 2.50 ; double Truck = 5.50; double Bus = 19.00; double rateC = 1.50; double rateT = 3.75; double rateB = 6.75; char type; cout << "Please Enter number of hours parked and the type of car (Type: (C)ar or (T)ruck or (B)us): " << endl; cin >> type >> hoursParked;...
I have a code and it works and runs as it supposed too. What is the...
I have a code and it works and runs as it supposed too. What is the UML for it? Any help will be awesome. Thanks. import java.util.Scanner; public class StringToMorseCode { public static void main(String[] args){ Scanner input = new Scanner(System.in);    char[] letters = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6',...
I need to update this program to follow the these requirements please and thank you :...
I need to update this program to follow the these requirements please and thank you : Do not use packages Every class but the main routine class must have a toString method . The toString method for Quadrilateral should display its fields: 4 Points. All instance variables should be declared explicitly private . Area incorrect : enter points no: 1 1 3 enter points no: 2 6 3 enter points no: 3 0 0 enter points no: 4 5 0...
C++ program, include comments stating what each part of code does please. I want to be...
C++ program, include comments stating what each part of code does please. I want to be able to understand it so I'll be more knowledgeable in the future. The program is multiple files(fibonacci.h file, fibonacci.cpp file, main.cpp file and loops_simple_data_test.cpp). After the directions I also included any starter code or comments left by my professor within the files to aide us. Directions: In folder 04_loops_simple_data write prototype and definition for string value - return function get_fibonacci with an int parameter...
JAVA question here, and thank you. I need ot update the following classes an fixme's on...
JAVA question here, and thank you. I need ot update the following classes an fixme's on this.canvas = null etc. Thanks! import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; import edu.luc.etl.cs313.android.shapes.model.*; /** * A Visitor for drawing a shape to an Android canvas. */ public class Draw implements Visitor<Void> { // TODO entirely your job (except onCircle) private final Canvas canvas; private final Paint paint; public Draw(final Canvas canvas, final Paint paint) { this.canvas = null; // FIXME this.paint = null; //...
I need a scholarship essay for my nursing program. please and thank you.
I need a scholarship essay for my nursing program. please and thank you.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT