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++: Early Objects
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)
- Area 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_forwardTrue/False 5. Keywords make good variable names.arrow_forward
- Vary the control variable from 1 to 100 in increments of 1 .for (unsigned int i{1}; i <= 100; i++)arrow_forwardcorrect all errors.arrow_forwardIn the expression, int n = rand() % 33 - 32; a. Generates a value in the range [-32, 0] b. Generates a value in the range [-32, 32] c. Generates a value in the range [0, 33] d. Generates a value in the range [-33, 0] e. Generates a value in the range [0, 32]arrow_forward
- 15. 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_forward6. Write a program segment using switch selection for the following statements. If the grade is A, print “Your CGPA is 4.0". If the grade is B, print “Your CGPA is 3.0". If the grade is C, print “Your CGPA is 2.0". If the grade is D, print “Your CGPA is 1.0".arrow_forwardc++arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,