Concept explainers
Rewrite the following
int selection;
cout << "Which formula do you want to see?\n\n";
cout << "1. Area of a circle\n";
cout << "2. Area of a rectangle\n";
cout << "3. Area of a cylinder\n"
cout << "4. None of them!\n";
cin >> selection;
1f (selection == 1)
cout << "Pi times radius squared\n";
else if (selection == 2)
cout << "Length times width\n";
else if (selection == 3)
cout << "Pi times radius squared times height\n";
else if (selection == 4)
cout << "Well okay then, good-bye!\n";
else
cout << "Not good with numbers, eh?\n";
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Computer Science: An Overview (12th Edition)
Absolute Java (6th Edition)
Database Concepts (7th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Question Write a Mat lab Code by which User can Plot 2 D and 3D graphs of different Functions by using the selection statements. Follow the instructions as given below: (i) User write "twoDimension" for 2 D graphs and "threeDimension" for 3D graphs in command window. (ii) For 2 D graphs use "trignometric" for 2D plot all trigonometric functions (i.e Sin, Cos, tan, Sce, Csc, Cot) and use "Intrignometric" for 2D plot of all inverse Trignometric functions (i.e asin,acos,atan,acot,asec,acse) (iii) For 3D graphs use "3D" for three dimensional plot of Sinc function by using Surf, Surfc, Pcolor commands. (iv) For Subplot of All 2D (Trigonometric and Inverse Trigonometric functions) and Subplot of all 3D graphs USE "Allsubplot" in command window and the user can see subplot of All 2D (Trigonometric and Inverse Trigonometric functions) and all 3D graphs separately in three different figures.arrow_forwardExercise II Write a program that finds the positive integer solutions of the following equation ax³ + bx² + cx' + d = 0. The user enters the values of coefficients a, b, c and d. The program should test each integer starting from -50 to 50, and each time the equation is equal to zero, it prints its value as well as "is a solution". At the end, it displays the total number of positive integers found. Note that if the equation has more than one solution, the plural word “solutions" is used in the output. Sample run 1: Enter the coefficient of a, b, c, d: 1 -8.5 21 -13.5 1 is a solution 3 is a solution The equation has 2 integers as solutions Sample run 2: Enter the coefficient of a, b, c, d: 6 48 103.5 67.5 The equation has no integer solutions Sample run 3: Enter the coefficient of a, b, c, d: 1 -1 -12 0 4 is a solution The equation has 1 integer solutionarrow_forwardIn Python Text-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. The selection variable must be sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. Add an if statement in the choice() function to make the correct selection.arrow_forward
- QUESTION5: The Speed of Sound. The following table shows the approximate speed of sound in air, water, and steel: Medium Speed Air Water Steel 2,100 feet per second. 3,900 feet per second. 14,400 feet per second. Write a program that asks the user to enter "air", "water", or "steel", and the distance that a sound wave will travel in the medium. The program should then display the amount of time it will take. You can calculate the amount of time it takes sound to travel in air with the following formula: Time = Distance* 1,100 You can calculate the amount of time it takes sound to travel in water with the following formula: Time = Distance/ 14,900. You can calculate the amount of time it takes sound to travel in steel with the following formula: Time - Distance/ 16.400.arrow_forwardQ1. FizzBuzz problem:- Write a program which return "fizz" if the number is a multiplier of 3, return "buzz" if its multiplier of 5 and return "fizzbuzz" if the number is divisible by both 3 and 5. If the number is not divisible by either 3 or 5 then it should just return the number itself? .arrow_forward1_ Write a program that reads a character and prints it only if it is 'y' or 'Y' (Simulation of If-Else then structure). 2_Write a program that prints the odd numbers between 1 and 10 using loop (Number 1 ASCII code is 49).arrow_forward
- In C++arrow_forwardArea and Perimeter: Write a program that prints the area and perimeter of a circle with a radius of 5.5 using the formula: Perimeter = 2 * radius * PI Area radius * radius * PI Use Math.PI for PI in your program.arrow_forward4. Complete the following program to draw four squares in random locations. Complete draw_square to draw a square. Complete draw_randsquare and main as instructed by the comments. Save & Run 11/1/2021, 4:15:21 PM - 2 of 2 import turtle 2 import random 3 4 def draw_square (t, sz) : 5 '''Draws a square of size sz using turtle t''' 6 pass #This statement does nothing - you can remove it 7 #Your code here use a loop to draw a square 8 for i in range (4) 9 t.forward (sz) 10 t.left (90) 11 12 def draw_randsquare (t, square_size) : 13 '''Uses draw square to draw a square in a random location''' 14 pass #This statement does nothing you can remove it 15 #Get a random x positionarrow_forward
- Draw the Boolean expression: *arrow_forwardTrue/False 5. Keywords make good variable names.arrow_forward15. Speed Conversion ChartYour friend Amanda, who lives in the United States, just bought an antique European sports car. The car’s speedometer works in kilometers per hour. The formulafor converting kilometers per hour to miles per hour is:MPH = KPH * 0.6214In the formula, MPH is the speed in miles per hour and KPH is the speed in kilometersper hour. Amanda is afraid she will get a speeding ticket, and has asked you to write aprogram that displays a list of speeds in kilometers per hour with their values convertedto miles per hour. The list should display the speeds from 60 kilometers per hourthrough 130 kilometers per hour, in increments of 5 kilometers per hour. (In otherwords, it should display 60 kph, 65 kph, 70 kph, and so forth, up through 130 kph.) made in visual studio 2017arrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning