Hi,

I am not good at programming at all and I need help with the questions below. Please help if you know how to solve them. Thankyou. Help with any of the questions is appreciated.

E.1. Question 1: Program Header

For this question you are asked to create a function that prints a header to the screen. This header will

include your

**name, lab number and question number**. An example of a header can be seen below.

You can design your header to be unique as long as the required information is present.

Program Requirements

•

The function you create will be required to accept two parameters: the lab number, and the

question number. When you call the function, you will pass these parameters which will be

displayed in the header.

•

Sample code is given for the ‘main’ function, which demonstrates how the function should be

called. You must write the code for the function call.

Sample Source Code

#include

<iostream>

#include

<string>

using namespace

std;

void

myHeader( int lab, int question); //Header function prototype

int

main()

{

myHeader( 4, 1);

} // end function main

// Write you code for your header function here…

Sample Output

*********************************

My Name

Lab #4, Question #1

*********************************

Press any key to continue . . .

3

E.2. Question 2: Simulating Rolling Of Dice

Using the rand function you are asked to write a program that simulates the rolling of a die a number of

times and count how many times it lands on a particular side..

Program Requirements:

•

Use the header function created in question 1.

•

When your program begins it will ask the user how many times you wish to roll the die, which

should be validated to be a positive number. The program will then ask which side of the die

you wish to count to see how often it is rolled. Verify this number to be between 1 and 6.

•

Write a function that takes accepts two arguments, the number of rolls and the side of the die to

count. The function should then simulate rolling the die the specified number of times and

count how many times the indicated side is rolled. When completed the function will **return**

the number of times the specified side was rolled. This function should use the

**srand and time**

functions to make the results ‘more random’ (

*see lecture slides/Functions – slide 37+)*

•

From the main function, display the results of the simulation similar to the sample output:

*********************************

My Name

Lab #4, Question #2

*********************************

This program uses a function that simulates

rolling the dice a number of times and counting

the number of times a particular side is rolled.

Please enter the number of times to roll the dice: 20

Please enter which side of the dice to count (1 - 6): 4

A 4 was rolled 5 times out of 20 (25%)

Press any key to continue . . .

E.3. Question 3: Calculating Sine and Cosine without the CMATH Library

For this question you are asked to calculate the value of the sine and cosine function

**without using **the

CMATH Library. The sine and cosine functions can be calculated (in radians) by using the following

summation:

Program Requirements:

•

Use the header function created in question 1.

•

Your program will begin by asking the user to enter the value of x (double), and the value of N

(integer) that is used in the summation loop. The program should **validate x **to make sure that it

is between and ( ), and also **validate N **to ensure it is a positive number.

The program will use function-calls to calculate the value of sin(x) and cos(x), **without using**

4

the cmath library

. The results of the calculations will then be displayed using **cout statements**

within the main function.

•

Your program will contain at least four functions (in addition to the header function):

o

Function to calculate the power function (base^exponent). This function will **accept**

two parameters as arguments, the base and the exponent, and will **return **the result of

the calculation.

o

Function to calculate the factorial function. This function will **accept **a double-type

number as a parameter and calculate its factorial. The function will then **return **this

result. Use double type variables to increase the range of numbers your function can

represent.

o

Function to calculate the sine function. This function will accept a double-type number

as a parameter and calculate its sine. This will be performed using the above formula

and using the power and factorial functions. You cannot use cmath for this lab.

o

Function to calculate the cosine function. This function will accept a number as a

parameter and calculate the cosine. This will be performed using the above formula and

using the power and factorial functions. You cannot use cmath for this lab.

o **There should be no cout statements outside of the main function.**