View the step-by-step solution to:

Question

# my code

when I prompt N or n at 'Would like to continue?' but my program not break, it still running.I want to know my mistake in this my code.I want the output same pic1.

The volume of the cylinder is 113.097
Would like to continue? Y
Invalid input. Try again.
The volume of the cylinder is 307.876
Would like to continue? N
Good bye !

C:\Users\ Test\ Desktop\Com Pro#1\Lab#9 (2).cpp - [Executing] - Dev-C+ + 5.11
X
File Edit Search View Project Execute Tools AStyle Window Help
TDM-GCC 4.9.2 64-bit Release
1 10 (globals
v
Project Classes Debug
[*] Lab#9 (2).cpp
JOUPUNK
#include &lt;iostream&gt;
#include &lt;iomanip&gt;
using namespace std;
C:\Users\Test\ Desktop\Com Pro#1\Lab#9 (2).exe
-
X
lease enter radius and height of a cylinder: 3 4
int main( ) {
The volume of the cylinder is 113. 112
float r,h;
Would like to continue? y
8
float num=0;
9
char c, n, N, y, Y;
Invaild input. Try again.
10 -
while (num&lt;=0 ){
11
12
The volume of the cylinder is 301. 632
Would like to continue? n
13
cin &gt; &gt; r;
cin &gt; &gt; h;
Good bye!
14
15
if(r &lt;= -1 | | h &lt;= -1 ){
cout &lt;&lt; &quot;Invaild input. Try again. \n&quot;;
16
Jelse{
17
18
cout &lt;&lt; &quot;The volume of the cylinder is &quot; &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; volume(r,h);
cout &lt;&lt; &quot;\nWould like to continue? &quot;;
19
cin &gt;&gt; c;
20
21
switch(c){
22
case 'n' :
cout &lt;&lt; &quot;Good bye!\n&quot;;
23
break;
case 'N' :
cout &lt;&lt; &quot;Good bye!\n&quot;;
break;
31 float volume(float radius, float height) {
up Compiler Resources lli Compile Log Debug [ Find Results \$3 Close
Abort Compilation
Warnings: 0
Output Filename: C: \Users\Test\Desktop\Com Pro#1\Lab#9 (2) . exe
Output Size: 1. 83487033843994 MiB
Compilation Time: 0. 69s
Shorten compiler paths
13
Col: 18
Sel:
0
Lines: 33
Length: 734
Insert
Done parsing in 0 seconds

Your program is not exiting after preesing n or N is because you are using switch... View the full answer

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents