EBK C++ PROGRAMMING: FROM PROBLEM ANALY
8th Edition
ISBN: 9781337514491
Author: Malik
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 4PE
Program Plan Intro
Program Plan
1. Variables mentioned below are used:
- shape- choice of a shape whose appropriate dimensions are to be entered [rectangle, circle, or cylinder].
- width- width of the rectangle.
- length − length of the rectangle
- radius- radius of circle or base radius of cylinder
- height − the height of the cylinder.
Program Description:
To rewrite the program after making corrections in the order of the statement so that the user is prompted to enter shape type and proper dimensions.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The statements in the following program are in incorrect order. Rearrange the statements so that they prompt the user to input the shape type (rectangle, circle, or cylinder) and the appropriate dimension of the shape. The program then outputs the following information about the shape: For a rectangle, it outputs the area and perimeter; for a circle, it outputs the area and circumference; and for a cylinder, it outputs the volume and surface area. After rearranging the statements, your program should be properly indented.
. The statements in the following program are in incorrect order. Rearrange the statements so that they prompt the user to input the shape type (rectangle, circle, or cylinder) and the appropriate dimension of the shape. The program then outputs the following information about the shape: For a rectangle, it outputs the area and perimeter; for a circle, it outputs the area and circumference; and for a cylinder, it outputs the volume and surface area. After rearranging the statements, you program should be properly indented.
using namespace std;
#include
int main ()
string shape;
double height;
#include > shape;
cout << endl;
if (shape = "rectangl e")
cout << "Area of the circle - "
<< PI* pow (radius, 2.0) << endl;
cout < "Circumference of the circle :
<< 2 * PIpow (radius, 2.0) << endl;
cout < "Enter the height of the cylinder: "
cin >> height
cout < endl;
cout < "Enter the width of the rectangle : "
cin >> width;
cout…
Airline companies apply baggage restrictions for their passengers. An
airline company has decided to apply a 10kg limitation for
passengers' hand luggage and 20kg for their normal baggage. When
passengers arrive, they enter their hand and normal luggage weight
from the keyboard. If passengers exceed their normal baggage
allowance of 10 dollars per gram, they pay 12 dollars per kg.
Accordingly, write the program that calculates the baggage price of
the airline they will go to according to the baggage values entered by
the arriving passenger and keeps this from closing the program for
each passenger. Note: If hand and normal baggage allowances are
stretched below the maximum value, the payment amount will be
considered not negative. An example printout is given on the right.
Geri bildirim gönder
Chapter 4 Solutions
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
Ch. 4 - Prob. 1TFCh. 4 - Prob. 6SACh. 4 - Prob. 12SACh. 4 - Write a program that prompts the user to input a...Ch. 4 - Write a program that prompts the user to output an...Ch. 4 - Prob. 4PECh. 4 - In a right triangle, the square of the length of...Ch. 4 - Write a program that mimics a calculator. The...Ch. 4 - Redo Exercise 8 to handle floating-point numbers....Ch. 4 - The number of lines that can be printed on a paper...
Ch. 4 - The short-term, 0-24 hours, parking fee, F, at an...Ch. 4 - Write a program to implement the algorithm that...Ch. 4 - Samantha and Vikas are looking to by a house in a...Ch. 4 - One way to determine how healthy a person is by...Ch. 4 - Ron bought several acres of farm to grow and sell...Ch. 4 - The cost of renting a room at a hotel is, say...Ch. 4 - Let l be a line in the x-y plane. If l is a...Ch. 4 - The first 11 prime integers are 2, 3, 5, 7, 11,...
Knowledge Booster
Similar questions
- do it fastarrow_forwardWrite a program that reads the length and width of a rectangle as integers from the keyboard and then calculates and printsa) the area of the rectangle, andb) The circumference of the rectangle.arrow_forward3. The formula for determining compound interest is: A represents the amount to earn; P is the principle that is initially invested; r is the interest rate earned; n is the number of times the interest is compounded; and t is the number of time periods for the investment. Write a program that prompts the user to enter P, r, n and t. The program should output the amount earned on the investment. 4. Look up the Pythagorean theorem if you are not already familiar with it. Use the following formula to solve for c in the formula: c = √a2 + b2. Use the proper functions from the cmath header file. Be sure to output the result.larrow_forward
- Given an airplane’s acceleration a and take-off speed v, you can compute the minimum runway length needed for an airplane to take off using the following formula: length = v2/2a Write a program that prompts the user to enter v in meters/second (m/s) and the acceleration a in meters/second squared and displays the minimum runway length.arrow_forwardMATLAB The Mach number is a critical quantity in aerodynamics. It is the ratio of the speed of an object (e.g., an aircraft) to the speed of sound. If the Mach number is less than 1, the flow is subsonic; if the Mach number is between (0.8-1.2), the flow is transonic; if the Mach number is equal to 1, the flow is sonic; if the Mach number is between (1.2 and 5), the flow is supersonic; if the Mach number is greater than 5, the flow is hypersonic. Write a script that will prompt the user for the speed of an aircraft and the speed of sound at the aircraft's current altitude and will print whether the condition is subsonic, transonic, sonic, supersonic or hypersonic.arrow_forwardQuestion: A country charges income tax as follows based on one's gross salary. No tax is charged on the first 20% of salary. The remaining 80% is called taxable income. Tax is paid as follows: 10% on the first $15,000 of taxable income; 20% on the next $20,000 of taxable income; 25% on all taxable income in excess of $35,000; Write a program to read a value for a person's salary and print the amount of tax to be paid in dollars. . ● . Additionalind.arrow_forward
- ] In a triangle, the sum of the lengths of any two sides is greater than the lengthof the other third side. Write a program triangle.cc that prompts a user to enterthe lengths of three sides, checks if they form a triangle, and outputs if it is an isosceles,equilateral, scalene, or right triangle. Also, your program should output the perimeter andthe area of the triangle. In a right triangle, the square of the length of one side is equalto the sum of the squares of the lengths of the other two sides. An isosceles triangle hastwo sides of equal length. An equilateral triangle has all three sides with the same length.A scalene triangle has no equal sides. Your program should define and use the followingfunctions:(a) isTriangle - takes the 3 sides of a triangle and returns true if they form a triangle,false otherwise.(b) isIsosceles - takes the 3 sides of a triangle and returns true if they form anisosceles triangle, false otherwise.(c) isEquilateral - takes the 3 sides of a triangle and…arrow_forwardThis program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then outputs the average grade for each student. It also outputs the highest grade earned in each test and the average of all grades in each test. Your output should look like this: Mary's average grade was 78.8% Harry's average grade was 67.7% etc... : : In test 1 the highest grade was 93% and the average was 89.2% In test 2........etc Your main method should be modular. Write a method that inputs the 5 names into an array (one dimensional), and returns this array to the main Write a method that inputs the 15 (integer) test grades into a (two-dimensional) array, and returns this array to the main Write a method that calculates the students averages and stores them in an array, and returns this array to the main Write a method that calculates the average grade for each test and stores them in an array, and returns this array to the main Write a method that determines the highest grade…arrow_forwardGiven the sample code above in generating a random number. Create a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice yet.) 2. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. (You can use a menu if you prefer.) 13. The computer's choice is displayed. 4. A winner is selected according to the following rules: a. If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.) b. If one player chooses scissors and the other player chooses paper, then scissor wins. (Scissors cuts paper.) c. If one player chooses paper and the other player…arrow_forward
- Develop a pseudocode or flowchart for all the following problems : 1. Write a program which will display “I AM GOOD” on the computer screen for 10x2. Write a program which will display “I AM GREAT” on the computer screen for 100x3. Write a program which will display “I AM SUPERMAN” on the computer screen for 1000x4. Accept two integers from computer user and check whether they are equal or not.5. Write a program to check whether a given number is even or odd.6. Write a program to check whether a given number is positive or negative7. Write a program to read the value of an integer m and display the value of n is 1 when m is larger than 0, 0when m is 0 and -1 when m is less than 08. Write a program which accept the user’s height in cm then display :a. You are so tall → if the height is more than 180cmb. You are not that tall → if the height is between 100 – 179cmc. You are short ha ha ha → if the height is less than 100cm9. Write a program to read 10 numbers from keyboard and find their…arrow_forwardPaula and Danny want to plant evergreen trees along the back side of their yard. They do not want to have an excessive number of trees. Write a program that prompts the user to input the following:a. The length of the yard.b. The radius of a fully grown tree.c. The required space between fully grown trees.The program outputs the number of trees that can be planted in the yard and the total space that will be occupied by the fully grown trees.arrow_forwardA contractor orders, say, 30 cubic yards of premixed concrete to construct a patio that is to be, say, four inches thick. The length of the patio is to be, say, twice the width. Write a program that prompts the user to specify the amount of premixed concrete (in cubic yards) ordered, the thickness of the patio (in inches), and the ratio of length and width. The program then outputs the length and width of the patio (in feet). (1 cubic yard 5 27 cubic feet.) (To find the square root of a decimal number, include the header file cmath using the statement #include <cmath>, in your program. The function sqrt, included in this header file, determines the square root of a decimal number. For example, sqrt(16.0) = 4.0.)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr