Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2.1, Problem 2STE
Give the declaration for two variables called count and distance count is of type int and is initialized to zero, distance is of type double and is initialized to 1.5.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that calculates the average of a group of test scores. You will ask
the user to input each test score individually. When calculating the average, the
lowest score in the group is dropped. Your program should use the following
functions:
void getScore() should ask the user for a test score, store it in a reference
parameter variable, and validate it. This function should be called by main once
for each of the five scores to be entered.
void calcAverage() should calculate and display the average of the four highest
scores. This function should be called just once by main and should be passed the
five scores.
int findLowest) should find and return the lowest of the five scores passed to it. It
should be called by calcAverage(), which uses the function to determine which of
the five scores to drop.
Void displayAverage() should display the average of the four highest scores. This
function should be called by calcAverage().
Input Validation: Do not accept test scores lower…
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…
Write another version of the checkeven function. This version receives 3 integer variables and returns true if all three numbers are even. Otherwise, the function returns false. Write the statements to read in three numbers and call the checkeven function. Then print YES if all three numbers were even, or print NO if they were not all even.
Chapter 2 Solutions
Problem Solving with C++ (10th Edition)
Ch. 2.1 - Give the declaration for two variables called feet...Ch. 2.1 - Give the declaration for two variables called...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Give a C++ statement that will increase the value...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Prob. 6STECh. 2.1 - Prob. 7STECh. 2.2 - Give an output statement that will produce the...Ch. 2.2 - Give an input statement that will fill the...Ch. 2.2 - Prob. 10STE
Ch. 2.2 - Write a complete C++ program that writes the...Ch. 2.2 - Write a complete C++ program that reads in two...Ch. 2.2 - Prob. 13STECh. 2.2 - Write a short program that declares and...Ch. 2.3 - Convert each of the following mathematical...Ch. 2.3 - Prob. 16STECh. 2.3 - What is the output of the following program lines...Ch. 2.3 - Write a complete C++ program that reads two whole...Ch. 2.3 - Given the following fragment that purports to...Ch. 2.3 - What is the output of the following program lines...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Suppose savings and expenses are variables of type...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Consider a quadratic expression, say x2 x 2...Ch. 2.4 - Consider the quadratic expression x2 4x + 3...Ch. 2.4 - What is the output of the following cout...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What output would be produced in the previous...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the most important difference between a...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - Write a complete C++ program that outputs the...Ch. 2.5 - The following if-else statement will compile and...Ch. 2.5 - Prob. 36STECh. 2.5 - Write a complete C++ program that asks the user...Ch. 2 - A metric ton is 35,273.92 ounces. Write a program...Ch. 2 - The Babylonian algorithm to compute the square...Ch. 2 - Many treadmills output the speed of the treadmill...Ch. 2 - Write a program that plays the game of Mad Lib....Ch. 2 - The following is a short program that computes the...Ch. 2 - A government research lab has concluded that an...Ch. 2 - Workers at a particular company have won a 7.6%...Ch. 2 - Modify your program from Programming Project 2 so...Ch. 2 - Negotiating a consumer loan is not always...Ch. 2 - Write a program that determines whether a meeting...Ch. 2 - Prob. 6PPCh. 2 - It is difficult to make a budget that spans...Ch. 2 - You have just purchased a stereo system that cost...Ch. 2 - Write a program that reads in ten whole numbers...Ch. 2 - Modify your program from Programming Project 9 so...Ch. 2 - Sound travels through air as a result of...Ch. 2 - Prob. 12PPCh. 2 - The HarrisBenedict equation estimates the number...Ch. 2 - Write a program that calculates the total grade...Ch. 2 - It is important to consider the effect of thermal...Ch. 2 - Prob. 16PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Ingredient Adjuster A cookie recipe calls for the following ingredients: 1.5 cups of sugar cup of butter 2.75 c...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Describe the three types of anomalies that can arise in a table and the negative consequences of each.
Modern Database Management
Write a default constructor and a second constructor for the class RatingScore, as described in Exercise 9 of t...
Java: An Introduction to Problem Solving and Programming (8th Edition)
1. Read the problem statement. 2. Formulate the algorithm using pseudocode and top-down, stepwise refinement. 3...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Find the no-load value of υo in the circuit shown.
Find υo when RL is 150 Ω.
How much power is dissipated in th...
Electric Circuits. (11th Edition)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
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
- in C++ Customers at a popular home improvement store come in and ask you how many pavers and how much gravel and sand they will need to install a patio. Write a program to calculate these quantities and also provide a cost estimate for the project. All your work will be done in the main function. First, you declare the variables needed for the calculation. After you write your class header, ask the customer to enter the patio’s width and length (in feet, a double or float). How many pavers will your customer need? First, calculate the patio area. There are many patterns for putting down pavers. Rather than lay out the exact pattern, allow 10% more square feet for pattern matching and waste. The pavers that you are selling today are 4 inches x 8 inches. Calculate the number of pavers needed and round up to the next whole paver. Next calculate the volume of gravel and sand needed for the patio: The volume of gravel needed for the base of the patio is enough to provide a base with…arrow_forwardUSE C++programming languagearrow_forwardA business that uses functions to calculate the weekly payment amounts of employees in a workplace.you are asked to write a program.The weekly payment amount of an employee depends on the following variables:- Number of hours worked - (minimum: 0, maximum: 60)- Hourly wage - (minimum: 0.00 TL, maximum: 30.00 TL)- Number of exemptions - (minimum: 0, maximum: 5)Using these 3 values,- Gross payment amount- General income taxLocal income tax- Social security amount- Net payment amountwill be calculated. →The maximum number of hours an employee can work before earning overtime pay is 40 hour. If the number of hours worked is less than or equal to 40, the gross payment amount will be equals the product of the wage. If the number of hours worked is more than 40, the gross payment amount is 40 times the hourly wage. plus 1.5 times the hourly rate for every hour over 40 →The general withholding tax is 55.77 TL for the weekly payment period. The employee is subject to general taxation the gross…arrow_forward
- Modify the program so that it does the following: Performs a function that gets the area of a rectangle. The function must receive two parameters (decimal numbers) that represent the base and height of the rectangle and must return the calculated value (decimal number). Perform a second function that obtains the total area of a rectangular prism with a rectangular base. The total area of such a prism is equal to the sum of the areas of each of its faces. It uses calls to the previous function for this calculation. Call this last function in the main with user data. Execution example Give me the base: 21.3 Give me the height: 10 Give me the depth: 2.0 The total area of the prism is: 551.2arrow_forwardI need help trying to write a program that simulates the condition you may find at a traffic light. The program should prompt the user to enter a value of G, Y, or R that corresponds to a green, yellow, or red light. However, in the case of a yellow light, the program should prompt the user to check for a police presence by entering a value of Y or N for yes or no. If there are no police in sight then proceed through the light, otherwise come to a complete stop. This program that I need help on uses an if-else statement. I use java eclipse. Thank you so mucharrow_forwardUsing Python, write an application that will calculate a loan payment. To complete this, you are required to write 2 functions, LoanPayment and InterestOnlyLoanPayment, as well as a test application that calls each of the functions to get the payment amount based on parameters supplied to the functions. The test application should output both the loan payment and the interest-only loan payment based on input values from the user. The LoanPayment function is defined as follows: Payment = Loan amount / Discount factor The discount factor is {[(1 + i)^n] - 1} / [i(1 + i)^n], where you have the following: n = Payments per year × Number of years i = Annual interest rate / Payments per year Take for example the following: D = {[(1 + 0.005)^360] – 1} / [0.005(1 + 0.005)^360] = 166.7916, where n = 12 × 30 and i = 0.06 / 12. Loan payment = $250,000 / 166.7916 = $1,498.88 The InterestOnlyLoanPayment is defined as follows: Interest-only payment = Loan amount × (Annual interest rate / 12) Take…arrow_forward
- You can find out how many seconds have elapsed since Jan 1, 1970 using the time() function. #include <time.h> now = time(NULL); // now is more than a billion seconds (which data type should you use?) Write a program that estimates how many years, months, weeks, days, and hours have gone by since Jan 1 1970 by calculations with the number of seconds that have passed. The number of months must be less than 12, i.e., take out how many years have gone by first, then how many months are left, then weeks, etc. Assume that all years have 365 days, and all months have 30.42 days. Don’t use a calculator, or any web site that reports the number of seconds in a month, etc. – your C program can calculate anything that you need. Notice that this is an assignment on using arithmetic in C. Hints. How many seconds are in a minute? hour? A day? A week? A month? A year?arrow_forwardWrite a function that checks whether an integer is an even digit or an odd digit integer using the following header: int getType(int n)arrow_forwardWrite the following function: Name: CylinderVolume Parameters: r (int), h (double) Calculate and return the volume of a cylinder The formula for volume of a cylinder is: Volume = pi*r2 * h In main() input the radius (int) and the height (double) of a cylinder. Then use the function CylinderVolum() to calculate the volume and then display the volume. Limit the output to 2 decimal places.arrow_forward
- Hi, need help to programming in JAVA language.arrow_forwardWrite a wholly creative quiz program that consists of three original questions that you make up according to these specifications: One question should require user input of type int One question should require user input of type float One should require a string input The quiz should be scored by using a counter variable that has an initial value of zero and is incremented by one for every correct answer. Provide feedback to the user for each question, and report the total score when the quiz has finished. Example runs not shown. It's a creative exercise. def main():points = 0states = int(input('How many states in the USA? '))if states == 50:points +=1print('Correct. Good job!')else:print('Sorry, the answer is 50') points = 0capital = input('What is the capital of England? ')if capital == "London":points+=1print('Correct. Well done.')else:print('Sorry, the answer is London .') points = 0points = float(input('How many points does a pentagram have? '))if points == 10:points…arrow_forwardWrite a program that computes the number of extraterrestrial civilizations capable of communicating with us. - The program should use the following as constants in accordance with Drake's calculations: R. = 1, f = 1, f₁ =1 - The program should prompt the user for the values of every other variable and store those variables as a data-type that makes sense given the type of information that the variable represents. - The program should compute the number of civilizations, N, and write this value to the console window.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
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