This page is located at http://www.cs.wpi.edu/~alvarez/CS1005/HW1/
Specifically, your program should prompt the user to input two positive (floating point) numbers, then compute the arithmetic and geometric means of these numbers, and finally report these means to the user. Careful documentation of your program is required. Further details are provided below.
int main() { FYI(); float num1 = GetNumber(); float num2 = GetNumber(); ReportArithmeticMean(num1, num2); ReportGeometricMean(num1, num2); return 0; }This decomposes your program into several chunks, each involving a call to a function.
Compile your program using the g++ compiler. Debug (fix) it as necessary, addressing any compiler error messages or warnings. It's good practice to write one function at a time, checking for errors or warnings before going on to the next function.
A script file containing three sample runs is shown below. Your script file may look slightly different, but the overall format should be more or less the same. In particular, note the format in which the output values are reported; your program should include brief explanations of how the values were computed, in the format shown below.
Script started on Fri Jan 14 18:50:20 2000 %hw1 This program computes the arithmetic and geometric means of two user-supplied positive numbers. Input a positive number and press enter: 2 Input a positive number and press enter: 4 The arithmetic mean of the two numbers is: (2+4)/2 = 3 The geometric mean of the two numbers is: (2*4)^(1/2) = 2.82843 %hw1 This program computes the arithmetic and geometric means of two user-supplied positive numbers. Input a positive number and press enter: 1 Input a positive number and press enter: 9 The arithmetic mean of the two numbers is: (1+9)/2 = 5 The geometric mean of the two numbers is: (1*9)^(1/2) = 3 %hw1 This program computes the arithmetic and geometric means of two user-supplied positive numbers. Input a positive number and press enter: 1.54 Input a positive number and press enter: 3.4925 The arithmetic mean of the two numbers is: (1.54+3.4925)/2 = 2.51625 The geometric mean of the two numbers is: (1.54*3.4925)^(1/2) = 2.31915 %exit exit script done on Fri Jan 14 18:51:03 2000