Question: Please do this as simple as possible and give explanations only at the beginner level this is for CS109. Code language is C++ Problems 2,

Please do this as simple as possible and give explanations only at the beginner level this is for CS109. Code language is C++

Problems 2, 3 and 4 are full programming exercises

1 ) Answer each of the short questions:

a) Write the function prototype for a function AreaCircle that takes radius (a float) as input and returns the area of the circle (also a float).

b) Declare a function SumDigits that has one input parameter N (an integer) and it returns an integer too.

c) Declare a function called PrintMenu that does not have any input parameter, and function displays a menu of a coffee shop,

d) Given a function prototype as below:

void Display(int a, int b, int c);

Write down the function call with values of a, b and c as 3, 4 and 5 respectively.

e) Given a function declaration as below:

float IncomeTax(float grossIncome, int n, float propertyTax);

n is number of dependents, grossIncome is the gross annual income of the person and propertyTax is tax on the property person owns.

Call this function to display the income tax of a person whose gross annual income is 70000.00, number of dependents are 2 and property tax is 7500.00

2. Write a program that will ask the user to enter any integer, and store that in a suitable variable, say N. Now write a function SumDigits that takes N as input and the function returns the sum of all the digits N contains. Call this function from main, and display the answer. The function SumDigits need to follow the algorithm given as below:

Declare sum and initialize to 0

Write a while loop using the condition that as long as N > 0, do the following:

sum = sum + N % 10

N = N/10

Return the sum

Test this program by entering (a) any 4, (b) 5 and (c) 6 digit integer as input, and each case copy the output and paste it below your program using block comment statements.

3) The ancient Greek mathematician Euclid developed a method for finding the greatest common divisor of two integers, A and B. His method is

If the remainder of A/B is 0, then B is the greatest common divisor

If it is not 0, then find the remainder of A/B and assign B to A and the remainder to B

Return to step a and repeat the process

Write a program that uses a function to perform the procedure. Main needs to call this function by sending inputs A and B (get user input for A and B first, in main), and display values of A, B and the greatest common divisor.

Run this program with A and B values in the range from (a) 10 to 100 and (b) in the range from 2000 to 5000

4) Write a program that uses a function BMI which computes and returns the body mass index (BMI) of a person using two input parameters: height and weight (height is in inches and weight in lbs) by using the following formula:

bmi = 703 x weight / (height)2

Now from main you call this function by using a nested loop, by varying the weight from 75 pounds to 225 pounds in steps of 5 lbs and inside the weight loop, vary the height by writing another loop, for height varying from 60 inches to 80 inches with steps of 2 inches, and inside the inner loop call the function to get the bmi, and display the weight, height and bmi in a table form. Display the bmi using a precision of 1. Your output should look like the below:

Weight Height

60 62 64 66 68 70 72 74 76 78 80

75 computed BMI values

80

85

90

95

.

The output should be displayed on the screen, as well as saved in an output file BMIchart.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!