4.8
4.9
4.7

Algorithm in C++. with extra credit.

Algorithm and tips for Assignment 4. Tip: Use the following code inside the main function to repeat your program without compiling it every
time: char response = ‘y’; while (response == ‘y’) { //most of your code goes here cout << "Would you like to run the program again? \n" << "Enter y for yes or n for no: "; cin >> response; } You can modify the code as you wish, just make sure the loop is intact Question 1 Algorithm 1) Declare your dimensions (i.e. length, width, height, radius, volume) 2) Get constant, for , store in pi 3) Inform user (via output) about selection of choices (You can use numbers or letters or symbols) 4) Get choices from user, store in choice 5) In switch statement: a. Create cases to match 6 choices and don t forget the default! b. For each case: i. Get dimensions for the choice (example: radius, and height for the cylinder) ii. Calculate volume using given formula (see assignment for formula. At this point,
you know how to express the formula in C++) iii. Don t forget to break after each case! 6) Apply while loop for repetition of program, using code from tip. Sample output for HW 4 Question: This program calculates the volume of several 3D objects. Here are your choices: Enter 1 for cylinder Enter 2 for sphere Enter 3 for pyramid Enter 4 for cone Enter 5 for cube Enter 6 for rectangular prism Please enter your choice now: 8
You have entered an invalid choice. Please run the program again. Would you like to run this program again? Enter ‘y’ for yes and ‘n’ for no: yThis program calculates the volume of several 3D objects. Here are your choices: Enter 1 for cylinder Enter 2 for sphere Enter 3 for pyramid Enter 4 for cone Enter 5 for cube Enter 6 for rectangular prism Please enter your choice now: 3
You wish to find the volume of a pyramid. Enter the length, width and height: 5 6 7
The volume of the pyramid is 70 cubic units. Would you like to run this program again? Enter ‘y’ for yes and ‘n’ for no: n Press any key to continue . . . Extra Credit Algorithm:
1) Get computer s randomly generated number, store in num
a. Seed the random number generator
b. Set the range of random numbers using random number formula 2) Create a variable for counting the number of guesses, store in tries 3) Get guesses from user, store in guess 4) Set up loop to compare guesses (see pseudocode)
while (they haven t guessed the number && they have tried to guess 5 or less times)
{
if (guess is less than number)
output guess is too low
else if (guess is greater than number)
output guess is too high
get another guess
increment tries
} 5) Output the value to be guessed
if (they guessed the number)
output congrats, and confirm the value they guessed by outputting num
else (if they haven t guessed the number and they used up all five tries)
tell the user that they lost and reveal the value in num 6) Apply while loop for repetition of program, using code from tip.Sample output for Extra Credit:
I’m thinking of a number between 1 and 100. Can you guess what it is?
You have five tries!
Nope, that’s too high.
Guess again: 64
Nope, that’s too high.
Guess again: 53
Nope, that’s too low.
Guess again: 57
Nope, that’s too high.
Guess again: 55
You used up all 5 tries!
The number I was thinking of was 56
Would you like to run the program again? Enter ‘y’ for yes or ‘n’ for no: y
I’m thinking of a number between 1 and 100. Can you guess what it is?
You have five tries!
Nope, that’s too low.
Guess again: 64
Nope, that’s too high.
Guess again: 48
Congratulations! You guessed it!
I was thinking of the number 48.
You took 3 tries!
Would you like to run the program again? Enter ‘y’ for yes or ‘n’ for no: n Press any key to continue . . .

Ordering Homework Writing Service

You can get our ideal online homework help services with four easy steps. All you have to do is inform us of your requirements. Immediately we will match with a specialist in your academic discipline. After that, we will track your order, review it to ensure it meets your requirements, and submit it to your email.

Submit Requirements

Fill in your assignment instructions on the order form

Quality review

We have a team of editors, who will thoroughly review your assignment, ensuring there are no errors before submission

Affordable

Budget-friendly writing services

Privacy

We don’t share our client’s information with a third party

Unique

We write every assignment from scratch

Amazing Homework Writing Features

Once you consult us for homework help online services, you will attest to why we are among the USA's best essay writing services.

Read on and find out some of the features that make our services superlative.

Free Homework Writing Services

Free plagiarism checker

You can confirm that the content you get is original for free using our plagiarism checker.

Free title page and bibliography

Once you place an order, we format it accordingly without demanding additional charges.

Free unlimited revisions

We offer free unlimited revisions until your assignment is of your desired quality..