Program C++, computer science homework help

User Generated

Wbqn

Computer Science

Description

Program1:

#include <iostream>

using namespace std;

//prototypes

void DemonstrateFunc1();

void DemonstrateFunc2(int num);

int main()

{

cout << "?. Execution starts with main. " << endl;

DemonstrateFunc1();

cout << "?. Then we come here. " << endl;

DemonstrateFunc2(100);

cout << "?. Finally we come here. "<< endl;

return 0;

}

//****************************

void DemonstrateFunc1()

{

cout << "?. This is a sample function." << endl;

}

//****************************

void DemonstrateFunc2(int num)

{

cout << "?. This is another sample function. " << endl;

cout << " num is an argument or parameter. " << endl;

cout << " The value of num is " << num << endl;

}

============================================================================================

What student should do :


Type in the above program including your name and date as a comment. Before running the

program, change each of the question marks to the numbers 1 through 5 indicating the order in

which that line will be executed. Run the program and check your numbers. Fix and rerun if

necessary.

Submit a copy of the program (5 points) and a copy of the program output (5 points).

===================================================================================================


Program 2:

what student should do:


Write a program that calculates the average of three test scores. The program should contain

three value-returning functions: main, getTestScore, and calcAverage. The main function

should call the get TestScore function to get, validate the score to make sure the value is

between 0 and 100, and return each of the three test score. The testscore may contain a decimal

place. (Hint: the main function will need to call the getTestScore function three times.) The

main function then should call the calcAverage function to calculate and return the average of

the three test scores. When the calAverage function has completed its task, the main function

should display the average on the screen.

Submit a copy of the program (30 points) and a copy of the program output for different

data sets. Make sure you include output for invalid test scores (10 points).

=================================================================================================================

//function prototypes

float getTestScore ( );

float calcAverage(float score1, float score2, float score3);

int main( )

{

float s1, s2, s3; //these variable are used to store test scores

float average;

//call getTestScore function to get the test scores

s1 = getTestScore();

s2 = getTestScore();

s3 = getTestScore();

//call calcAverage to calculate the average of three test scores

average = calcAverage(s1, s2, s3);

// display the average

cout << "average of three test scores ("<<s1<<","<<s2<<","<<s3<<") is: "<<

average<<endl;

return 0;

}

//function definitions/implementation getTestScore function gets a test score from the user and

// validates the score to make sure the value is between 0 and 100. If the score is out of range

// getTestScore function allows the user to re-enter the score. This function returns a valid score

to // the caller function

float getTestScore ( )

{

//Implement the function

}

//calcAverage function calculates and returns the average of the three test scores passed to

//the function as input.

float calcAverage(float score1, float score2, float score3)

{

//Implement the function

}

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

You didn't answer so I choos...


Anonymous
Excellent resource! Really helped me get the gist of things.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Content

Related Tags