Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 1, Problem 5P
Modify the C++
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C++ program to calculate total ordering cost. Jacob is a retailer for ice. Normally a bag of ice costs $2.5, but the price varies with the amount that he purchases. The following table shows the discount that Jacob receives.
In your program, define variables with meaningful names to accept user input on order volume, and calculate total ordering cost based on the order volume inputted. Use if-else statements to handle the calculations for different order volumes as shown in the above table.
Your program should print out user order volume, discount rate, and total ordering cost in console
Order Volume
Discount Rate
>= 200 bags
25% off
120 - 199 bags
20% off
60 - 119 bags
15% off
40 - 59 bags
10% off
20 - 39 bags
5.5% off
0 - 19 bags
No discount
Write a C program which calculates and prints the number of whole days and hours in a given number of hours.
There are 24 hours in a day. You will need to use the integer division operator / to calculate the number of whole days and the modulus (remainder) operator % to calculate the number of remaining hours. The output of your program should have the following format.
130 hours is equivalent to 5 days and 10 hours.
Please do not change the provided code.
Provided code:
#include <stdio.h>
int main()
{
int number_of_hours;
scanf("%d", &number_of_hours);
//type your code here
return 0;
}
For example:
Write a program in C++ that should calculate the insurnace for a house.
use questions below to write your programm.
what is your first?
what last name?
how many people are living in the houes?
how much did you bought the house for?
how many bedrom does it have?
what is the lenght in squre feet?
- use Loop so everyone can repeat the programm.
use function like "viod" and any other function.
and finally use this formula:
X/150*y/*50
x is the total price of the house
y is the number of bedrooms
s is the lenght in square feet.
Chapter 1 Solutions
Problem Solving with C++ (10th Edition)
Ch. 1.1 - Prob. 1STECh. 1.1 - What would be the data for a program to add two...Ch. 1.1 - Prob. 3STECh. 1.1 - What is the difference between a machine-language...Ch. 1.1 - What is the role of a compiler?Ch. 1.1 - What is a source program? What is an object...Ch. 1.1 - What is an operating system?Ch. 1.1 - What purpose does the operating system serve?Ch. 1.1 - Prob. 9STECh. 1.1 - Prob. 10STE
Ch. 1.1 - Prob. 11STECh. 1.2 - An algorithm is approximately the same thing as a...Ch. 1.2 - Prob. 13STECh. 1.2 - Prob. 14STECh. 1.2 - Prob. 15STECh. 1.3 - If the following statement were used in a C++...Ch. 1.3 - What is the meaning of \n as used in the following...Ch. 1.3 - What is the meaning of the following statement...Ch. 1.3 - What is the meaning of the following statement...Ch. 1.3 - What is the meaning of this directive? # include...Ch. 1.3 - What, if anything, is wrong with the following...Ch. 1.4 - Prob. 22STECh. 1.4 - Prob. 23STECh. 1.4 - If you omit a punctuation symbol (such as a...Ch. 1.4 - Omitting the final brace } from a program produces...Ch. 1.4 - Prob. 26STECh. 1.4 - Suppose you write a program that is supposed to...Ch. 1 - Using your text editor, enter (that is, type in)...Ch. 1 - Modify the C++ program you entered in Practice...Ch. 1 - Further modify the C++ program that you already...Ch. 1 - Modify the C++ program that you entered in...Ch. 1 - Modify the C++ program that you entered in...Ch. 1 - Prob. 6PCh. 1 - Write a C++ program that reads in two integers and...Ch. 1 - Write a program that prints out C S ! in large...Ch. 1 - Write a program that allows the user to enter a...Ch. 1 - Write a program that allows the user to enter a...Ch. 1 - Write a program that inputs a character from the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Write for statements that print the following sequences of values: 1, 2, 3, 4, 5, 6, 7 3, 8, 13, 18, 23 20, 14,...
C How to Program (8th Edition)
Use the following tables for your answers to questions 3.7 through 3.51 : PET_OWNER (OwnerID, OwnerLasst Name, ...
Database Concepts (7th Edition)
If the following statement were used in a Java program, it would cause something to be written to the screen. W...
Absolute Java (6th Edition)
Write a function called c that takes as its argument a d structure as defined in this chapter. The function sho...
Programming in C
Write a loop equivalent to the for loop above without using .
C Programming Language
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 this chapter, you learned that although a double and a decimal both hold floating-point numbers, a double can hold a larger value. Write a C# program named DoubleDecimalTest that declares and displays two variables-a double and a decimal. Experiment by assigning the same constant value to each variable so that the assignment to the double is legal but the assignment to the decimal is not. In other words, when you leave the decimal assignment statement in the program, an error message should be generated that indicates the value is outside the range of the type decimal, but when you comment out the decimal assignment and its output statement, the program should compile correctly.arrow_forward1) Write a c++ program that calculates the cost of 3 bags of fruit. The 4 possible fruits arepears which cost 1 dollar each, pomegranites which cost 2 dollars each, plumbs whichcost 3 dollars each, and bananas which cost 5 dollars each. Each bag can contain anynumber of different fruits with any quantity of each particular fruit. The program willprompt the user to enter a particular fruit by typing the name of the fruit: .‘pear’ forpears, ‘pomegranite” for pomegranites, ‘plumb’ for plumbs, and ‘banana” for bananas,and then prompt for the quantity of that fruit that will be placed in the bag. The programwill then continue to prompt the user in the same manner for more fruit to be placed inthe same bag until the user types the word ‘done’. This will then cause the program tohave the user enter the various quantities of fruit for the next bag. When the user hasentered the varieties of fruit in all 3 bags, the program will display the total cost of fruitper bag and the overall cost for all…arrow_forward2 When you deposit money in a savings account at a bank, the bank pays you interest on that money. If the bank computes the interest and adds it to your account once every year, the bank compounds interest annually. If you deposit p dollars, the money in your account after n years at interest rate r is : p(1+r)n Create a WCF service for that question, write a C# program that asks the user for the initial amount, the interest rate and the number of years. and then displays the balance after that many years. Do not hard code any variable values. The client will be prompted for any required variable values.arrow_forward
- Write a C program that computes the employee’s payroll of ABC Company. The user is first asked to enter the employee’s name, hourly wage, and number of hours worked for the week. Then when that is done the employee’s data, which consist of the employee’s name, their gross (wages * hours), and their Net (gross after a 12% tax rate and 50 pesos insurance fee mandatory to all employees), has to be shown. (Use #include <stdio.h> instead of #include <iostream>. Please Enter Employee’s Name: Juan dela CruzPlease Enter Employee’s Hourly Wage: 115.75Please Enter Employee’s Hours Work this Week: 40 Employee’s Payslip: Employee’s Name: Juan dela Cruz Hourly Rate: 115.75 Hour’s Work: 40 Gross Income: 4630.00 Insurance Fee: 50.00 Tax Fee: 555.60 Net Income: 4024.40arrow_forwardInstructions In this chapter, you learned that although a double and a decimal both hold floating-point numbers, a double can hold a larger value. Write a C# program named DoubleDecimalTest that declares and displays two variables—a double and a decimal. Experiment by assigning the same constant value to each variable so that the assignment to the double is legal but the assignment to the decimal is not. In other words, when you leave the decimal assignment statement in the program, an error message should be generated that indicates the value is outside the range of the type decimal, but when you comment out the decimal assignment and its output statement, the program should compile correctly. Note: Leave the decimal assignment statement in the program on final submission to receive full credit.arrow_forwardCreate a C++ program that will input name, no of units enrolled, fee per unit and mode of payment, and will output. Please use #include Name: Tuition Fee = No. of units enrolled*fee per unit Discount or Interest Total Fee = Tuition Fee +/- Discount/Interest Mode of Payment ; Discount/Interest C (Cash) : 5% Discount I (Installment) / 10% Interestarrow_forward
- In C++, write a program that calculates and prints a monthly paycheck for an employee. The net pay is calculated after taking the following deductions from the employee's gross salary: Federal Income Tax: 17.5% State Tax: 9.1% Social Security Tax: 6.2% Medicare Tax: 1.45% Retirement Plan: 9.29% Health Insurance: $51.48 Life Insurance: $3.71 Your program will prompt the user to input the employee ID, the employee name, and the employee's monthly gross salary. The program will calculate the deductions listed above, along with the percentage of take home pay (defined as the net pay divided by the gross salary). After calculating each deduction and percentage, the output will be printed to the screen (see example output below). Requirements All decimal numbers must be formatted to 2 decimal places. Ask for the employee's ID first, then full name (can include spaces), then the salary. The prompt to enter the salary must include the employee name. The employee ID MUST be…arrow_forwardYou’re given coins of different denominations and a total amount of money. From that, you need to write a function to compute the fewest number of coins that you need to make up that amount. If you can’t reach the given amount of money with any combination of the coins, you return -1. Write the code in the C++ languagearrow_forwardin c++ please A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline consumed by the user’s car and the number of miles traveled by the car and will then output the number of miles per gallon the car delivered. Your program should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the number of miles per gallon. Your program should use a globally defined constant for the number of liters per gallon.arrow_forward
- Program for C# Instead of assigning a value to the inches variable, accept the value from the user as input. Display the measurement in both inches and centimeters—for example, if inches is input as 3, the output should be: 3 inches is 7.62 centimeters.arrow_forwardIn C Declare a variable of type double.- Ask the user for a value and place it in the declared variable.- Write code to check for and output statement stating whether the variable is zero, positive, ornegative.- Declare a variable of type character.- Ask the user for a letter and place it in the declared variable.- Write code to check for and output statement stating whether the variable is an upper caseletter, lower case letter, or not a letter (neither of the above).- Write a simple program that is a four function calculator that displays a menu with options a to add, s to subtract, m to multiply, and d to divide two numbers. Ask the user for two float variables in each operation and output the result.arrow_forwardNeed help with a C++ program Write a C++ program that helps a person determine how long they can hike for under various conditions on a given supply of water. Your program should prompt the user to enter how much water they can carry in liters. Then, for each of the following conditions, print out how many hours the user can hike for. - moderate temperature, moderate difficulty: 1/2 liter per hour- moderate temperature, high difficulty: 3/4 liter per hour- high temperature, moderate difficulty: 1 and 1/2 liters per hour- high temperature, high difficulty: 1 and 3/4 liters per hour SAMPLE OUTPUT Hello! Welcome to the Hiking Water Calculator!How many liters of water can you carry? 8 OK. Here is how long you can hike for on 8 liters of water under the following conditions: moderate temperature, moderate difficulty: 16 hoursmoderate temperature, high difficulty: 10.6666666 hourshigh temperature, moderate difficulty: 5.3333333 hourshigh temperature, high difficulty: 4.5714285 hours.…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,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License