C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
8th Edition
ISBN: 9781337684392
Author: Malik, D. S.
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 1, Problem 17SA
Explanation of Solution
Algorithm step | C++ instruction (code) |
Get the radius | cin >> radius ; |
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
The volume of a sphere is (4.0/3.0)πr 3 and the surface area is 4.0πr 2, where r is the radius of the sphere. Given the radius, design an algorithm that computes the volume and surface area of the sphere. Also using the C++ statements provided for Example 1-1, write the C++ statement corresponding to each statement in the algorithm. (You may assume that π = 3.141592.)
The volume of a sphere is (4.0 / 3.0)pr3 and the surface area is 4.0pr2, where r is the radius of the sphere. Given the radius, design an algorithm that computes the volume and surface area of the sphere. Also using the C++ statements provided for Example 1-1, write the C++ statement corresponding to each statement in the algorithm. (You may assume that p = 3.141592.)
PLEASE USE THE SWITCH-CASE STATEMENT FOR THIS PROBLEM
The Kingdom of Aleria uses gold coins and other metals for their money and their exchange rate is as follows:
50 copper = 10 nickel
30 nickel = 18 silver
15 silver = 1 gold
Based on their exchange rate, create a C program that would accept a number of gold coins ad the user's choice of unit output (S- silver, N-Nickel, C- Copper). The program will then display the equivalent number of coins.
Chapter 1 Solutions
C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
Ch. 1 - 1. Mark the following statements as true or...Ch. 1 - Prob. 2SACh. 1 - Prob. 3SACh. 1 - Prob. 4SACh. 1 - Prob. 5SACh. 1 - Prob. 6SACh. 1 - In a C++ program, preprocessor directives begin...Ch. 1 - Prob. 8SACh. 1 - Prob. 9SACh. 1 - Prob. 10SA
Ch. 1 - Prob. 11SACh. 1 - Prob. 12SACh. 1 - Design an algorithm to find the weighted average...Ch. 1 - Prob. 14SACh. 1 - Prob. 15SACh. 1 - 16. The dealer’s cost of a car is 85% of the...Ch. 1 - Prob. 17SACh. 1 - 18. Tom and Jerry opened a new lawn service. They...Ch. 1 - 19. Jason typically uses the Internet to buy...Ch. 1 - Prob. 20SACh. 1 - Prob. 21SACh. 1 - A student spends a majority of his weekend playing...Ch. 1 - You are given a list of students names and their...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Data processing) Years that are evenly divisible by 400 or are evenly divisible by 4 but not by 100 are leap years. For example, because 1600 is evenly divisible by 400, 1600 was a leap year. Similarly, because 1988 is evenly divisible by 4 but not by 100, it was also a leap year. Using this information, write a C++ program that accepts the year as user input, determines whether the year is a leap year, and displays a message telling the user whether the entered year is or is not a leap year.arrow_forward(Acoustics) The loudness of a sound is measured in units of decibels and is calculated as shown: 10LOG(SL/RL) SL is the intensity of the sound being measured. RL is a reference sound-intensity level. Using this formula, write a C++ program that calculates and displays the decibel loudness of a busy street having a sound intensity of 10,000,000 RL. Verify your program’s result by doing a hand calculation. After verifying that your program is working correctly, use it to determine the sound level in decibels of the following sounds: a.Awhisperatsoundintensity200RLb.Arockbandplayingatsoundintensity1,000,000,000,000RLc.Anairplanetakingoffatsoundintensity100,000,000,000,000RLarrow_forward(Physics) A golf ball is dropped from an airplane. The distance, d, the ball falls in t seconds is given by the formula d=gt2, where g is the acceleration caused by gravity and is equal to 32ft/sec2. Using this information, write and run a C++ program that displays the distance fallen in each 1-second interval for 10 seconds and the total distance the golf ball falls at the end of each interval. The output should complete the following chartarrow_forward
- Numerical analysis) Given a number, n, and an approximation for its square root, a closer approximation of the actual square root can be found by using this formula: newapproximation=(n/previousapproximation)+previousapproximation2 Using this information, write a C++ program that prompts the user for a number and an initial guess at its square root. Using this input data, your program should calculate an approximation of the square root that’s accurate to 0.00001. (Hint: Stop the loop when the difference between the two approximations is less than 0.00001.)arrow_forward(Electrical eng.) For the series circuit shown in Figure 3.16, the voltage drop, V2 , across resistor R2 and the power, P2 , delivered to this resistor are given by the formulas V2=IR2andP2=IV2,whereI=E/(R1+R2). Using these formulas, write, compile, and run a C++ program that prompts users for values of E, R1, and R2 ; calculates the voltage drop and power delivered to R2 ; and displays the results. Check your program by using the test data E=10volts,R1=100ohms,andR2=200ohms. After finishing your verification, use your program to complete the following chart:arrow_forwardUsing the formula below which calculates the distance between two points, (x1, y1) and (x2, y2) in the Cartesian plane: Sqrt ( (x2-x1)2 + (y2-y1)2 ) where sqrt represents square root This formula can be used to find the radius of the circle given a centre and a point on the cicle. Write an interactive C program that prompts the user to enter a point on the circle and the centre. The program should then output the circumference, area, diameter and circle’s radius. Your program must have at least the following functions: i)area: This function takes as its parameter a number that represents the radius of the circle and returns the circle’s area. (If r is the radius, the area is πr2.) Assume that π = 3.1416. ii)circumference: This function takes as its parameter a number that represents the radius of the circle and returns the circle’s circumference. (If r is the radius, the circumference is 2πr.) iii)radius: This function takes as its parameters 4 numbers that represent a…arrow_forward
- Write a C++ program to display the table given below. Use manipulator functions. You need to apply the formula for calculating percentage value as shown in the table. Also check which student got the lowest percentage among all. All marks and percentages need to be stored in separate variables.arrow_forwardPLEASE ANSWER USING C++ Program Specifications: Write a program to calculate U.S. income tax owed given wages, taxable interest, unemployment compensation, status (single or married), and taxes withheld. Taxpayers are only allowed to use this short form if adjusted gross income (AGI) is less than $120000. Dollar amounts are displayed as integers with no comma separators. For example, cout << "Deduction: $" << deductionStep 1 . Input wages, taxable interest, unemployment compensation, status (1=single and 2=married), and taxes withheld as integers. Calculate and output AGI (wages + interest + unemployment). Output error message if AGI is above $120000 and the program stops with no additional output. Submit for grading to confirm two tests pass.Ex: If the input is: 20000 23 500 1 400 The output is: AGI: $20523 Ex: If the input is: 120000 23 500 1 400 The output is: AGI: $120523 Error: Income too high to use this form Step 2. Identify deduction amount based on status: (1)…arrow_forwardWrite a C statement to accomplish each of the following tasks.c) Set variable sum to 0.arrow_forward
- Write a single C statement or line that accomplishes each of the following:c) State that a program performs a sample payroll calculation (i.e., use text that helps todocument a program).arrow_forwardA milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a C++ program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.arrow_forwardDesign, write and compile, and run a C++ program to convert temperature in degrees Fahrenheit to degree Celsius. This is the equation for this conversion: Celsius = 5.0/9.0 (Fahrenheit – 32.0) Have your program convert and display the Celsius temperature corresponding to 98.6 degrees Fahrenheit. Your program should produce the following display (replacing the underline with the correct values): For a Fahrenheit temperature of _____ degrees, The equivalent Celsius temperature is ______ degrees.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr