Question Details

(Solved by Expert Tutors) Could u please help me with this zybooks questions? The root>


The root

mean square is a specific kind of average which is used for various purposes. It is given by the formula shown?here. This means that a sequence of values is squared and summed, then divided by the count of the values; the entire calculation is then square-rooted. Ask the user for input; stop when the user enters -1. Be sure to use the?square?and?squareRoot?functions you used in "Gentle" exercise 9.1. Here is a sample run:
Enter a positive number: 1Enter a positive number: 2Enter a positive number: 3Enter a positive number: 4Enter a positive number: 5Enter a positive number: -1The root mean square is 3.31662

Here is my code:
#include <iostream>
#include <math.h>


using namespace std;


int square(int);
double squareRoot(int);


int main()
{
int sum = 0;
int avg = 0; // To store mean of all the squared values
int counter = 0; // To store the no. of values entered by the user.
int n; // To store the value entered by the user.
double rms; // To store the final rooted mean value of the squared numbers


do{
cout << "Enter a positive number: "<<n<<endl;
cin >> n;


// If user enters the value for n as -1
if (n == -1)
break;


counter += 1; // Increment value of counter by 1 each time user enters a value


sum = sum + square(n); // Square and add


}while (n != -1); // Stop getting input when user enters -1


avg = sum / counter; // Mean of all the values


rms = squareRoot(avg); // RMS value


cout << "nThe root mean square is " << rms;


return 0;
}


// Function square() to return square of a number
int square(int n){
return n*n;
}


// Function squareRoot() to return the square root of a number
double squareRoot(int avg){
return sqrt(avg);
}




But didn't go though the zybooks, it said:

 


Solution details:

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Apr 19, 2020

EXPERT

Tutor

ANSWER RATING

YES, THIS IS LEGAL

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now