Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 1, Problem 9PP
The video game machines at your local arcade output coupons depending on how well you play the game. You can redeem 10 coupons for a candy bar or 3 coupons for a gumball. You prefer candy bars to gumballs. Write a
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 how much money you’ll end up with if you invest an amount of money at a fixed interest rate, compounded yearly. Have the user furnish the initial amount, the number of years, and the yearly interest rate in percent. Some interaction with the program might look like this:
Enter initial amount: 3000 Enter number of years: 10 Enter interest rate (percent per year): 5.5 At the end of 10 years, you will have 5124.43 dollars.
You arrive in front of a bridge that you must cross to reach a village before dark. Crossing the bridge is not free - the bridgekeeper asks you to roll two dice to determine the cost. You decide to write a program to verify that he is charging the right price.
Your program should read two integers, between 1 and 6, representing the values of each die. If the sum is greater than or equal to 10, then you must pay a special fee (36 coins). Otherwise, you pay twice the sum of the values of the two dice. Your program must then display the text "Special tax" or "Regular tax" followed by the amount you have to pay on the next line.
Write a program that requests the user to enter the total purchase in dollars and cents ( for example, $23.65, $45.00, etc) and outputs the discount in dollars and cents. If the total purchase is less than 200 dollars, there is no discount. If the total purchase is more than 200 dollars but less than or equal to 1000 dollars, then the discount is 15%, and if the total purchase is more than 1000 dollars, then the discount is 30%. At this store, a student always gets 30% discount on all purchases. Include this information in your codes.
Chapter 1 Solutions
Absolute C++
Ch. 1 - A metric ton is 35,273.92 ounces. Write a program...Ch. 1 - A government research lab has concluded that an...Ch. 1 - Workers at a particular company have won a 7.6 pay...Ch. 1 - Negotiating a consumer loan is not always...Ch. 1 - Write a program that determines whether a meeting...Ch. 1 - Prob. 6PPCh. 1 - One way to measure the amount of energy that is...Ch. 1 - The Babylonian algorithm to compute the square...Ch. 1 - The video game machines at your local arcade...Ch. 1 - Write a program that allows the user to enter a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Define each of the following terms: entity type entity-relationship model entity instance Attribute relationshi...
Modern Database Management
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
The same rules for naming variables apply to naming classes.
Starting out with Visual C# (4th Edition)
What is the difference between operating system software and application software?
Starting Out With Visual Basic (7th Edition)
Write a program that reads in five amounts of money, doubles each amount, and then writes out the doubled value...
Problem Solving with C++ (9th 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
You are to write a simple program that asks the user for input, processes theinput, and then outputs a result back to theuser.
Read in the following
Name of customer
Car Type (Compact, Midsize, Sedan)
Number of week days
Number of weekend days(Weekends are Saturday, Sunday)
Amount customer paid for Rental
Use the standard national average for car rental to calculate the national cost of rental based on car selection and days used by customer
Compare your result with what the customer paid and determine whether the rental was. a.Expensive(the rental is expensive if it costs $5 morethan national average)b.Bargain(the rental is a bargain if it costs $5 less thannational average)c.Average(the rental is average if it is atthe $5 range plus or minus from thenational average)
arrow_forward
In your favorite open world adventure video game, currency conversion is as given below:
1 Gold coin
23 Bolts
1 Gem
13 Gold coins
Write a program that takes a number of Bolts as user input (as an integer) and converts it to the number of whole Gems, Gold coins, and Bolts as shown below. The conversion information between these measurement metrics is provided in the table above. The number of Bolts should be converted in such a way that maximizes the whole number of Gems and Gold coins.
Expected output 1 (bold is user input)
Enter the number of Bolts: 32 0 Gems(s) 1 Gold coin(s) 9 Bolt(s)
Expected output 2 (bold is user input)
Enter the number of Bolts: 3000 10 Gem(s) 0 Gold coin(s) 10 Bolt(s)
The file should be named as convertCurrency.cpp. Don’t forget to head over to Coderunner on Canvas and paste your solution in the answer box!
arrow_forward
Write a program which prompts the user for a number and prints the numbers from 1 up to that number, one per line, and then prints out "That's all!". Some of the code has been provided for you.
For example, if the user enters 3 the program should print:
arrow_forward
Write a program that prompts the user to enter the year and first day of the year, then displays the first day of each month in the year. For example, if the user entered the year 2013, and 2 for Tuesday, January 1, 2013, your program should display the following output: January 1, 2013 is Tuesday ... December 1, 2013 is Sunda
arrow_forward
You have been asked to write a program to play rock-paper-scissors.
Your program will ask the user to input a number 0, 1, or 2 to denote rock, paper, and scissors respectively.
Your program will then randomly generate a number 0, 1, or 2 to denote the computer’s hand.
The rules for the game are:
•A scissor can cut paper.
•A rock can knock a scissor.
•A piece of paper can wrap a rock.
Let the game run continuously until either the user or the computer wins 3 times, displaying the outcome of each hand. At the end of the game, display a message indicating whether the user or the computer wins
Helpful Hint:
import random
player2= random.randint(0, 2)
arrow_forward
Write a program that begins by reading a number of cents from the users as an integer (this is input from the user).
Your program should then compute and display the denominations of the coins that should be used to give that amount of change to a shopper in coin denominations (Assume that the change machine is loaded with pennies, nickels, dimes, quarters, loonies and toonies).The change should be given using as few coins as possible. For example : you input 455 cents, it tells you that you have:
2 Toonies
2 quarters
1 nickle
REMEMBER : you need to work with remainders and floor division
arrow_forward
Write a program that calculates and prints the total bill at a restaurant. Prompt the user for the cost of the meal and then ask if a tip will be added. If it is, prompt for the tip percent as an integer. Of course, the tip percent should not be requested if no tip will be added. Finish by printing the meal cost, tip amount, and total bill.
Sample OutputEnter total cost of the meal 80Are you adding a tip? y/n yEnter the tip percent as an integer 25Here is your bill.Meal cost $80.00Tip $20.00Total cost $100.00
arrow_forward
Write a program that calculates the estimated hours and minutes for a trip given the number of miles traveled and the speed in miles per hour.
Specifically, write a program that
Welcomes the user to the Travel Time Calculator.
Asks user for number of miles traveled(allow user to enter fractional values)
Asks user for the speed in miles per hour (allow user to enter fractional values)
Calculates the number of hours and minutes for the trip to the nearest integer value. Hint: You can use the built-in function round that rounds a given number to the rounded integer value. e.g. round(4) will return 4, round(4.125) will return 4, round(4.5) will return 4 and round (4.75) will return 5.
Prints the number of hours and minutes for the trip.
Here are some sample runs:
arrow_forward
Write a program for a Bookstore to take an order from a customer, calculate how much to charge a customer based on his/her order, and display a receipt. The store sells only three books, designated by their authors: Cervantes ($41.25 each), Homer ($15.85 each), and Shakespeare ($30.50 each).
Your program is to work as follows:
Display a welcome message (e.g., “Welcome to the Bookstore!”)
Prompt the user for his/her first name
Prompt the user to input the number of books by Cervantes s/he wants
Prompt the user to input the number of books by Homer s/he wants
Prompt the user to input the number of books by Shakespeare s/he wants
Compute the total amount due, including a 10% sales tax
Display amount due
Ask the user how much money s/he will pay
Display a receipt listing the name of the user, the quantity of each item ordered, the total cost of the order, and the amount the user will have left after paying
Execution of the compiled program should appear roughly as follows (with red…
arrow_forward
You are to write a program to tell you how many months it will take to pay off a loan, as well as the total amount of interest paid over the life of the loan.
You have just purchased a stereo system that costs $1000 on the following credit plan: No down payment, an interest rate of 18% per year (and hence 1.5% per month), and monthly payments of $50. The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt. Hence, the first month you pay 1.5% of $1000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt which leaves you with a debt of $965.00. The next month you pay interest of 1.5% of $965.00, which is $14.48. Hence, you can deduct $35.52 (which is $50 - $14.48) from the amount you owe.
Write a program that will tell you how many months it will take you to pay off the loan, as well as the total amount of interest paid over the life of the loan. Use a loop to calculate the amount…
arrow_forward
Write a program that allows a player to play Rock, Paper, and Scissors against the computer. In this version, if there is a tie the computer wins. The user must beat the computer to win around.The player will provide their name and the number of rounds they want to play. They will begin by entering their name and the number of rounds they would like to play. For each round, the player will input a character to represent their play (‘R’ for rock, ‘P’ for paper, or ‘S’ for scissors). The program will randomly select its play and output whether the player won or lost. After all, rounds have been completed the program will output the match-winner. In the case that the player wins the match, it will output their percentage of wins otherwise it will output the percentage of losses. Use the following functions / descriptions for your code. You may (should) add more functions as you deem necessary, but you may not omit or modify the functionality described below (Don’t forget you will also…
arrow_forward
Write a program which prompts the user for a Celsius temperature, convert the
temperature to Fahrenheit, and print out the converted temperature.
Write a program which prompts the user for a Celsius temperature, convert the
temperature to Fahrenheit, and print out the converted temperature.
arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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