Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming: You must use a while loop as instructed for this task. Do not use functions, arrays or struct statements. Please write the code

C++ Programming: You must use a while loop as instructed for this task. Do not use functions, arrays or struct statements. Please write the code with same format in the code below.

Here is the code that needs to be modified:

//header files #include

using namespace std;

//main function int main()

{ //variable declaraion double radius; //the radius of the trough's end double width; //the width of the trough double volume; //the volume of water

//user input cout > radius; cout > width;

//calculation volume = 0.5 * 3.1415 * radius * radius * width * 1000;

//print output cout

return 0; }

Here is the task:

image text in transcribed

1. (10 marks) Modify the sample solution program to Question 1 of Assignment 2 to obtain a program that will meet the following specifications. Your program must prompt the user to enter the dimensions of a semi-circular trough in meters then determine the volume of water the trough can hold in liters, repeatedly until a non-positive value is entered for wither dimension. You must use a while loop to implement the program repeatedly asking for trough dimensions until a non-positive integer is entered. Your program should act EXACTLY as seen in the test runs below (including alignment) Notes: You may let TT 3.1415, 1 m 1000 L, and the volume of the pictured trough is V Tr W Test run 1 (0.25 radius and 1.5 width input by the user): Trough Volume Calculator Enter the radius and width in meters (space delimited) 0.025 1.5 Your trough can hold 147.258 L of water Enter the radius and width in meters (space delimited) 0.42 3 Your trough can hold 83 1.241 L of water. Enter the radius and width in meters (space de limited) 0.1 63 Your trough can hold L of water The user terminate his program Test run 2 (0.42 radius and 3 width input by the user): Trough volume Calculator Enter the radius and width in meters (space delimited) 0 4.2 The user terminated this program. HINT: Change the program to implement the change in prompts first. When that is working change the program by adding a while loop to classify five integers repeatedly. Carefully consider what must happen before entering the loop, inside the loop, and after the loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

To solve p + 3q = 5z + tan( y - 3x)

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago