Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Test 1-09/24/2018 1. Answer the following questions: 1.1 Complete the following

ID: 3753395 • Letter: T

Question

Test 1-09/24/2018 1. Answer the following questions: 1.1 Complete the following phrase: "If a C++ project employs functions it is recommended that the following parts are present:the 1.2. If the following is a function call, what are the identifiers between parenthesis called?: the function's call, and the function definition." x computeAveragely, z) 1.3. If x, y, z in the question above are integers, write what the prototype of the function computeAverage() should be? 2. For the given code include ciostream> using namespace std ?2?2 void main 0 char gender: int age double HR cout 0) cout>gender; Ef (genderM'11 (gender'm' HR 220-age: else if-( ( gender -.F' ) Il t gender-- ,t' } } cout

Explanation / Answer

Answer 1:

Part 1.1: the function declaration

"If a C++ project employees functions it is recommended that the following parts are present: the function declaration, the function's call, and the function definition."

------------------------

Part 1.2: Arguments

If " x= computeAverage(y,z); " is a function call , than the identifiers between parenthesis called arguments.

*An argument is the value that is passed to the function by the caller.

------------------------------

Part 1.3: Integer

If x,y,z in the question above are integers, than the prototype of the function computeAverage() should be integer because the value computed by function using integers and it is assign to an integer .

----------------------------------------------------------------------------------------------------------------------------------------

Answer 2:

Part 2.1:The general comments:

/*
This program is for computing the heart rate on the basis of gender and age of person.
In this program taking input as gender and age of person from user and giving the output as HR(Heart rate).Here heart rate is calculating in a loop till the user enters age as zero .
*/

-------------------------------------------

Part 2.2  

if(!((gender=='M')||(gender=='m')||(gender=='F')||(gender=='f')))
{
cout<<"Enter only Male or Female ";
cin>>gender;
}

so the program will be:

#include <iostream>

using namespace std;

void main()
{
char gender;
int age;
double HR;
  
cout<<"Please input your age(end with 0)";
cin>>age;
while(age>0)
{
cout<<"Please input your gender(M or F)";
cin>>gender;
if(!((gender=='M')||(gender=='m')||(gender=='F')||(gender=='f')))
{
cout<<"Enter only Male or Female ";
cin>>gender;
}

if((gender=='M')||(gender=='m'))
HR=220-age;
else if((gender=='F')||(gender=='f'))
HR=206-0.88*age;
cout<<"Your maximum normal hear rate is : "<<HR<<endl<<endl<<endl;
cout<<"Please input your age(end with 0)";
cin>>age;
}

}

-----------------------------------------------------

Part 2.3 :

double ComputeHR(int age, char gender)
{
double HR;
if((gender=='M')||(gender=='m'))
HR=220-age;
else
if((gender=='F')||(gender=='f'))
HR=206-0.88*age;
  

return HR;
}

So the program will be:

#include <iostream>

using namespace std;

double ComputeHR(int age, char gender)
{
double HR;
if((gender=='M')||(gender=='m'))
HR=220-age;
else
if((gender=='F')||(gender=='f'))
HR=206-0.88*age;
  

return HR;
}
void main()
{
char gender;
int age;
double HR;
cout<<"Please input your age(end with 0)";
cin>>age;
while(age>0)
{
cout<<"Please input your gender(M or F)";
cin>>gender;
if(!((gender=='M')||(gender=='m')||(gender=='F')||(gender=='f')))
{
cout<<"Enter only Male or Female ";
cin>>gender;
}
HR=ComputeHR(age,gender);
cout<<"Your maximum normal hear rate is : "<<HR<<endl<<endl<<endl;
cout<<"Please input your age(end with 0)";
cin>>age;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote