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 2, Problem 10PP
Modify your program from
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
A supermarket is doing a sales promotion for soft drinks. If one day you buy soft drinks and bring the empty bottles the next day, they exchange each set of K empty bottles for a full one. A customer wants to make the most of this offer and therefore bought several bottles on the first day of the promotion. Now he wants to know how many bottles he will have at the end of the second day of the promotion if he use it to the fullest.
Make a program to calculate this.
Input
The first input line contains integer T (1 ≤ T ≤ 10000), which indicates the number of test cases. In each of the following T lines come two integers N and K (1 ≤ K, N ≤ 10000), respectively the number of soft drinks bought and the number of empty bottles to gain a full.
Output
For each test case print the number of bottles that the customer will have on the second day, if he makes the most of the offer.
Hi, I need help with the following assignment.
Implement a program that reads in a year and outputs the approximate value of a Ferrari 250 GTO in that year. Use the following table that describes the estimated value of a GTO at different times since 1962.
Year
Value
1962-1964
$18,500
1965-1968
$6,000
1969-1971
$12,000
1972-1975
$48,000
1976-1980
$200,000
1981-1985
$650,000
1986-2012
$35,000,000
2013-2014
$52,000,000
I need this in Python
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
Calories from Fat and Carbohydrates A nutritionist who works for a fitness club helps members by evaluating the...
Starting Out with Programming Logic and Design (4th Edition)
Look at the following pseudocode. If it were a real program, what would it display? Declare Integer number1 = 1...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
In an IfThenElseIf statement, what is the purpose of a trailing Else?
Starting Out With Visual Basic (7th Edition)
Write Java code to display the largest and smallest values of type double that you can have in Java.
Java: An Introduction to Problem Solving and Programming (7th Edition)
Even though a binary file is not a text file, it can contain embedded text. To find out if this is the case, wr...
Java: An Introduction to Problem Solving and Programming (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
- Write a program that asks users when their birthday is. Use information provided to give them their astrological sign. Each of the twelve signs should display a different horoscope. Use the following dates for each sign, keeping in mind that both month and day must be evaluated for an accurate result. Aries: March 21–April 20 Taurus: April 21–May 21 Gemini: May 22–June 21 Cancer: June 22–July 22 Leo: July 23–August 22 Virgo: August 23–September 23 Libra: September 24–October 23 Scorpio: October 24–November 22 Sagittarius: November 23–December 21 Capricorn: December 22–January 20 Aquarius: January 21–February 19 Pisces: February 20–March 20arrow_forwardkindly change the program following the procedure on the problem. please list the changes you have made on the program t..thank youarrow_forwardkindly change the program following the procedure on the problem. please list the changes you have made on the program t..thank youarrow_forward
- Write a program that computes the earnings per shift for a babysitter. A babysitter charges $10 per hour before noon and $15 after noon. The program reads the starting time in hours and minutes and the ending time in hours and minutes. All times are between 8:00 am, and 7:59 pm, using a 12-hour clock. For example, you should consider hour 8 as 8 am and hour 6 as 6pm. The program should check the validity of the inputs as follows. 1) Hours are from 0-11 (0 for noon). 2) Minutes are from 0-59. 3) The start time must be before noon. 4) The end time must not be before 1pm. The program should display specific warnings regarding the above when the user submits invalid input; the program should prompt the user to re-enter the times again. The program should output the total hours worked and the total earnings per shift. Example: >9h 20m to 6h 15m You have worked 8 hours and 55 minutes in this shift, earning $120.417 Important Notes: Please do this in C++ Programming Do not use any…arrow_forwardJava: Receives a phrase and returns the converted phrase to Pig Latin. A word is translated into Pig Latin according to the following rules: a. If there are no vowels in the word, then add “ay” to the end of it. (a, e, i, o, and u are all the vowels considered). b. If the word begins with a vowel, then add “yay” to the end of it. c. Otherwise, take all the letters up to the first vowel and move those letters to the end then add “ay”. Sample Input: System.out.println(toPigLatin("I am fluent in Pig Latin")); System.out.println(toPigLatin(“Hey”)); Sample Output: Iyay amyay uentflay inyay igPay atinLay Heyayarrow_forwardWrite a program that outputs all the integers between 100 and 1000 (inclusive), that are divisible by 5 and also 6. (This means start at 100 and go up to 1000, but only output integers that are divisible by both 5 and 6.) Remember what "divisible" means - if a number is divisible by 5, there is no remainder when you divide it by 5. If a number is divisible by 6, there is no remainder when you divide it by 6. In javaarrow_forward
- How do I write this java program? The manatees have been streaming many movies over the course of the last year. You have been asked to determine the movie they think will win "Best Aquatic Feature Film." For your convenience, the movies are numbered (1 <= N <= 50,000) and the actual titles of the movies are not important. The manatees have voted in two rounds, and number of votes received for each movie is recorded. As many as 109109 manatees world-wide may vote. The K (1<=K<=N) movies with the most votes in the first round will advance to the second round. The winner is the movie with largest vote total in the second round. Ties are broken in both cases by picking the movie with the higher index number. Determine which movie comes in first place and which movie comes in last place in the second round. Input format All the input comes from the standard input stream. Line 1: Two space-separated integers: N and K Lines 2..N+1: Line i+1 contains two space-separated integers:…arrow_forwardWrite a python program that computes the zakat, obligatory charity, on camels. The program asks the user to input the number of camels, and then the zakat is calculated based on the following table: Rule for computing the zakat of 121 camels or more: You need to find the combinations of 40 camels and 50 camels that will minimize the number of “left over” camels not being “counted” in the zakat. For example, for 130 camels, we have (2*40) + (1*50)=130, with no left overs, and hence, the zakat consists of 2 bint Laboun and 1 Hiqqah. When we have 145 camels, we have the following scenarios: 1. (140) + (250) = 140 with 5 camels left over, 2. (240) + (150) = 130 with 15 camels left over, 3. (340) + (050) = 120 with 25 camels left over. Therefore, in this case the zakat is 1 bint Laboun and 2 Hiqqah, following the first scenario. Important Notes: Make sure that the input value is a positive integer. If not, the program must print the following message: Wrong input. Number should be an…arrow_forwardWrite a program that reads a list of names and total points for students until -1 is entered. After gettingall of names and points, it will output them as names and grades. Write your program using a functionthat gets the points as parameter and calculates the grade and return it. No input validation is required.Also write a function that unit test your grade calculator function.Bonus (5 points): validate your input in any way that you think works better for this situation.Show an error messageBring the points to a valid rangeReturn a value that shows an error has occurredA[94,100] A-[90,94) B+[87,90) B[84,87) B-[80,84) C+[77,80) C(74,77) C-[70,74) D+[67,70) D[61,67) F[0,61)Sample input:Lee 39Lua 86Mary 91Stu 72-1Sample output:Lee FLua BMary AStu C-arrow_forward
- The Research team led by Bernadette Wolowitz at Cal-tech University has discovered a new Amoeba that grows in the order of a Fibonacci series every month. They are exhibiting this amoeba in a national. conference. They want to know the size of the amoeba at a particular time instant. If a particular month's index is given, write a program to display the amoeba's size. For Example, the size of the amoeba on month 1, 2, 3, 4, 5, 6,... will be 0, 1, 1, 2, 3, 5, 8.... respectively.arrow_forward1.Write program to iteratively compute Fibonacci numbers (named after an Italian mathematician).Some Fibonacci numbers are 1, 1, 2, 3, 5, 8, ... where the next number is found by summing the preceding two numbers. Your program will read in a number, like 7, report the first 7 numbers. in this case1,1,2,3,5,8,13. Your program is not assured of receiving good data, thus if -2 is received as the number of numbers, then an error should be reported.arrow_forwardProblem 7: Guess the price of the car!? You will implement a variant of the number guessing game we played in lecture. In this variant, you will ask the user to guess the price of a $42,500 car. Let's assume that the player knows the price of the car is rounded to the nearest $500. If a player's guess is not exactly correct, your program will tell them they are either too high or too low. The player will get as many guesses as they need to guess the price of the $42,500 car. However they will only win the game if they used 5 or fewer guesses. Here are two examples of how the program should work for both cases: Guess the price and win the prize! Enter your guess:50000 Too high! Enter your guess:40000 Too low! Enter your guess:45000 Too high! Enter your guess:42500 You won the car! Guess the price and win the prize! Enter your guess:46000 Too high! Enter your guess:45000 Too high! Enter your guess:44000 Too high! Enter your guess:43000 Too high! Enter your guess:42000 Too low! Enter your…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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY