Absolute C++
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 10PP

(You should do Programming Projects 4.6 and 4.9 before doing this programming project.) Write a program that combines the functions of Programming Projects 4.6 and 4.9. The program asks the user if he or she wants to convert lengths or weights. If the user chooses lengths, then the program asks the user if he or she wants to convert from feet and inches to meters and centimeters or from meters and centimeters to feet and inches. If the user chooses weights, a similar question about pounds, ounces, kilograms, and grams is asked. The program then performs the desired conversion. Have the user respond by typing the integer 1 for one type of conversion and 2 for the other. The program reads the user’s answer and then executes an if -else statement. Each branch of the if -else statement will be a function call. The two functions called in the if-else statement will have function definitions that are very similar to the programs for Programming Projects 4.6 and 4.9. Thus, these functions will be fairly complicated function definitions that call other functions; however, they will be very easy to write by adapting the programs you wrote for Programming Projects 4.6 and 4.9. Notice that your program will have if-else statements embedded inside of if-else statements, but only in an indirect way. The outer if-else statement will include two function calls, as its two branches. These two function calls will each in turn include an if-else statement, but you need not think about that. They are just function calls and the details are in a black box that you create when you define these functions. If you try to create a four-way branch, you are probably on the wrong track. You should only need to think about two-way branches (even though the entire program does ultimately branch into four cases). Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program.

Blurred answer
Students have asked these similar questions
Write the following function to draw a regular polygon:def drawPolygon(x = 0, y = 0, radius = 50, numberOfSides = 3):The polygon is centered at (x, y) with a specified radius for the bounding circle for the polygon and the number of sides. Write a test program that displays a triangle, square, pentagon, hexagon, heptagon, and octagon, as shown in Figure 6.12a.
Exercise 4: Write a program that reads two pieces of information: the hourly wages and the number of hours worked by the employee. The program should then calculate the net salary of the employee and display the results as shown in Figure 4. Note that: the net salary of the employee is the sum of the basic wages (which is number of hours worked times the hourly wages) minus the Social Security fees; where the Social Security fees represent 10% of the Basic wages. Name your program Lab3_Id_ex4.py, where Id is your university Id. Include the design of your solution as comments at the beginning of your program. Test your solution with different input data. Please enter the employee hourly wages? 10 please enter the number of hours worked? 40 Basic Salary Hourly Wages Number of Social Net Salary Hours Security **** 10.000 40.00 400.000 40.000 360.000 **** Figure 4: Exercise 4 Sample Run
Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered: • The number of days spent in the hospital • The daily rate Hospital medication charges • Charges for hospital services (lab tests, etc.) The program should ask for the following data if the patient was an outpatient: • Charges for hospital services (lab tests, etc.) • Hospital medication charges The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the inpatient data, while the other function accepts arguments for outpatient information. Both functions should return the total charges and display it for the user. After the total charges have been calculated and displayed, write the result to a file, PatientReport.txt. You can use the techniques you learned in Chapter…

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY