C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Chapter 6.3, Problem 4E
Program Plan Intro
Program Plan:
- hundreds,fifties,twenties,tens,fives,ones, andamountvariables are used in the program.
- change() function converts the passed integer amount into equivalent parameters such as hundreds,fifties,twenties,tens,fives, and ones.
- int main() function is used to read input from user, calling change() function and displaying the calculated results to the user.
Program Description: The main purpose of the program is to converts the user entered amount into equivalent parameters such as hundreds,fifties,twenties,tens,fives, and ones.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Multiples) Write a function isMultiple that determines for a pair of integers whether thesecond integer is a multiple of the first. The function should take two integer arguments and return1 (true) if the second is a multiple of the first, and 0 (false) otherwise. Use this function in a programthat inputs a series of pairs of integers.
(python)
Is the statement true or false?
If you give a parameter a default value in the function definition, then that parameter is optional when calling that function.
(Use Python) Use the Design Recipe to write a function called compute_commission that returns the commission earned by a salesperson for the sale of a car. The function should consume two parameters, first a string representing the model of the car sold and the second an int representing the number of extra features that were sold. The commission follows these rules:
The commission earned on a basic model (“basic”) is $1000, on a mid-range model (“mid”) is $1500 and on a luxury model (“luxury”) is $2000. You may assume that these are the only three string values that will be passed to your function.
The salesperson earns $100 per extra feature sold. You may assume the value for the extra features is always greater than or equal to zero.
Include a docstring!
Write 3 assert_equal statements to test your function.
Chapter 6 Solutions
C++ for Engineers and Scientists
Ch. 6.1 - (Practice) For the following function headers,...Ch. 6.1 - Prob. 2ECh. 6.1 - Prob. 3ECh. 6.1 - (Statics) A beam’s second moment of inertia, also...Ch. 6.1 - (Statics) An annulus is a cylindrical rod with a...Ch. 6.1 - Prob. 6ECh. 6.1 - (Physics) Buoyancy is the upward force a liquid...Ch. 6.1 - (Numerical) a. Write a C++ program that accepts an...Ch. 6.1 - (Practice) a. Write a function that produces a...Ch. 6.1 - Prob. 10E
Ch. 6.1 - Prob. 11ECh. 6.1 - Prob. 12ECh. 6.1 - Prob. 13ECh. 6.1 - Prob. 14ECh. 6.1 - Prob. 15ECh. 6.2 - Prob. 1ECh. 6.2 - (Practice) For the following function headers,...Ch. 6.2 - (General math) a. Write a function named...Ch. 6.2 - (General math) a. The volume, V, of a cylinder is...Ch. 6.2 - Prob. 6ECh. 6.2 - Prob. 10ECh. 6.2 - (Numerical) a. The following is an extremely...Ch. 6.2 - Prob. 12ECh. 6.2 - Prob. 13ECh. 6.3 - Prob. 2ECh. 6.3 - Prob. 4ECh. 6.3 - Prob. 5ECh. 6.4 - (Practice) The volume, v, and side surface area,...Ch. 6.4 - (Practice) Write a C++ program that accepts the...Ch. 6.4 - (Simulation) Write a program to simulate the roll...Ch. 6.4 - (Numerical) Write a program that tests the...Ch. 6 - Prob. 1PPCh. 6 - Prob. 2PPCh. 6 - Prob. 6PPCh. 6 - (Numerical) Heron’s formula for the area, A, of a...Ch. 6 - Prob. 10PP
Knowledge Booster
Similar questions
- (included Question 1 for reference)arrow_forward(Wattan Corporation) is an Internet service provider that charges customers a flat rate of $7.99 for up to 10 hours of connection time. Additional hours or partial hours are charged at $1.99 each. Write a function charges that computes the total charge for a customer based on the number of hours of connection time used in a month. The function should also calculate the average cost per hour of the time used (rounded to the nearest 0.01), so use two output parameters to send back these results. You should write a second function round_money that takes a real number as an input argument and returns as the function value the number rounded to two decimal places. Write a main function that takes data from an input file usage.txt and produces an output file charges.txt. The data file format is as follows: Line 1: current month and year as two integers Other lines: customer number (a five-digit number) and number of hours used Here is a sample data file and the corresponding output file:…arrow_forward(Wattan Corporation) is an Internet service provider that charges customers a flat rate of $7.99 for up to 10 hours of connection time. Additional hours or partial hours are charged at $1.99 each.Write a function charges that computes the total charge for a customer based on the number of hours of connection time used in a month. The function should also calculate the average cost per hour of the time used (rounded to the nearest 0.01), so use two output parameters to send back these results.You should write a second functionround_money that takes a real number as an input argument and returns as the function value the number rounded to two decimal places. Write a main function that takes data from an input file usage.txt and produces an output file charges.txt. The data file format is as follows:Line 1: current month and year as two integersOther lines: customer number (a five-digit number) and number of hours usedHere is a sample data file and the corresponding output file:Data file…arrow_forward
- (Fibonacci) The Fibonacci series0, 1, 1, 2, 3, 5, 8, 13, 21, …begins with the terms 0 and 1 and has the property that each succeeding term is the sum of the twopreceding terms. a) Write a nonrecursive function fibonacci(n) that calculates the nth Fibonaccinumber. Use unsigned int for the function’s parameter and unsigned long long int for its returntype. b) Determine the largest Fibonacci number that can be printed on your system.arrow_forward(C program only) 2: Return structure from a function Create a function that will get information of students using structure. When the function is called it will return a structure. The returned structure is displayed from the main() function. Input 1. name Constraints accept string until \n is encountered 2. age Constraints The input must be an integer value Output Enter student name: Juan deal CruzEnter age: 18 Displaying Information:Name: Juan dela CruzAge: 18arrow_forward(Perkovic, Problem 6.31b) Write a function testCraps that accepts a positive integer n as an input, simulates n games and craps, and returns the fraction of games the player won. ⚫ the testCraps function should not make dice rolls directly, instead... testCraps function should call the craps function repeatedly and keep track of the results • if you your craps and testCraps function simulate the game correctly without any extra rolls, you should be able to hit the results below exactly 1 >>> random.seed(0) 2 >>> testCraps (10000) 3 0.5 4 >>> random.seed(1) 5 >>> testCraps (10000) 6 7 8 0.4921 >>> [(i, random.seed(i), testCraps (100*i)) for i in range(1,10)] [(1, None, 0.49), (2, None, 0.46), (3, None, 0.47333333333333333), (4, None, 0.5125), (5, None, 0.476), (6, None, 0.47333333333333333), (7, None, 0.4514285714285714), (8, None, 0.48), (9, None, 0.4855555555555556)] 9 >>arrow_forward
- (use Python)Define a function named get_user_number which has no parameters. When called, it gets a number between 1 and 100 (both inclusive) from the user and returns this value. Any other entries by the user are ignored and another value must be entered until they enter a valid number in this range. You may assume that the user types a valid number. For example: Test Input Result print(get_user_number()) -100 0 67 67arrow_forward(Hypotenuse) Define a function hypotenuse that calculates the length of the hypotenuse of a right triangle when the other two sides are given. Use this function in a program to determine the length of the hypotenuse for each of the triangles shown below. The function should take two double arguments and return the hypotenuse as a double. Sample output Enter 2 sides of right triangle: 3.0 4.0 Hypotenuse: 5.0 Enter 2 sides of right triangle: 5.0 12.0 Hypotenuse: 13.0 Enter 2 sides of right triangle: 8.0 15.0 Hypotenuse: 17.0arrow_forward(Use Python) The function course_average should calculate and return the average of the three values pass to it. The function main should ask the user to enter three grades and then pass these values to the course_average function. This function should also display a message to the user in the format below. For example, if the user entered 100, 90 and 95 the message would be:The average of 100 , 90 and 95 is 95arrow_forward
- (Exponentiation) Write a function integerPower(base, exponent) that returns the value ofbaseexponentFor example, integerPower(3, 4) = 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer, and base is an integer. Function integerPower should use for to control the calculation. Donot use any math library functions.arrow_forward(Use Python)Use the Design Recipe to define a function called is_multiple that consumes two parameters num1 and num2 in that order and returns True if num1 can be divided evenly by num2 otherwise it returns False. Include a docstring! Write 3 assert_equal statements to test your function.arrow_forward(Perfect Numbers) An integer number is said to be a perfect number if its factors, including1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 =1 + 2 + 3. Write a function isPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect.Challenge the power of your computer by testing numbers much larger than 1000.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education