Concept explainers
A video club wants to reward its best members with a discount based on the member’s number of movie rentals and the number of new members referred by the member. The discount is in percent and is equal to the sum of the rentals and the referrals, but it cannot exceed 75 percent. (Hint: Math.min.) Write a
Here is a sample run:
Enter the number of movie rentals: 56
Enter the number of members referred to the video club: 3
The discount is equal to: 59.00 percent.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Experiencing MIS
Data Mining for Business Analytics: Concepts, Techniques, and Applications with XLMiner
Starting Out with Python (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Database Concepts (7th Edition)
- When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first months interest on $1,000 is 1000 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 6 = 19. This means after making the first payment, the loan amount is 1,000 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 5.89 = 19.11 and the remaining balance after the second payment is 981 19.11 = 961.89. This process is repeated until the loan is paid. Write a program that accepts as input the loan amount, the interest rate per year, and the monthly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first months interest, then after each payment, the loan amount will increase. In this case, the program must warn the borrower that the monthly payment is too low, and with this monthly payment, the loan amount could not be repaid.)arrow_forward(Statistics) This is the formula for the standard normal deviate, z, used in statistical applications: z=(X)/ X is a single value. refers to an average value. refers to a standard deviation. Using this formula, you need to write a program that calculates and displays the value of the standard normal deviate when X=85.3,=80,and=4. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. d. Test the formula written for Exercise 7c, using the data given in the problem.arrow_forward2. Party shop sells birthday gift bags in two ways. set of 12 bags for $17.99 or an individual bag for $1.75. Customers can purchase a Write a complete program that asks the user input for the number of gift bags need to be purchased (an integer) and outputs the total price of the purchase. a) For example, if the customer buys 14 gift bags, the customer would be charged for 1 set of (12 bags) plus another 2 individual bags. The subtotal would be 1 (17.99) + 2 (1.75) = $21.49. b) Use a constant variable to set a fixed tax rate of 8.875. c) Display correct dollar values (2 decimal places, use cout precision). User input can be any content and it's bold and italicized for clarity. Example Output 1 Welcome to Party Shop! How many gift bags would you like to purchase: 14 SHOPPING CART 1-set (s) $17.99 2-individual $3.50 Subtotal: $21.49 Таx: $1.91 Total: $23.40 Thank you shopping Party Shop! Example Output 2 Welcome to Party Shop! How many gift bags would you like to purchase: 11 SHOPPING…arrow_forward
- Given the sample code above in generating a random number. Create a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice yet.) 2. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. (You can use a menu if you prefer.) 13. The computer's choice is displayed. 4. A winner is selected according to the following rules: a. If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.) b. If one player chooses scissors and the other player chooses paper, then scissor wins. (Scissors cuts paper.) c. If one player chooses paper and the other player…arrow_forwardA pendulum is simply a weight attached to a fixed point, usually through a string or a rod, and it swings freely backward and forward. The period of a pendulum is the amount of time that it takes to go from one point to another as it swings. Length of pendulum SWING T = PERIOD of the swing The formula to compute the period (7) is the following: T = 2π g=9.8 m/sec² L is the arm length of pendulum in meters. The unit of the period (7) is seconds. Write a program that will generate a table that will show the period (7) for several pendulums with lengths (L) in the range 10cm ≤L≤ 100cm in increments of 2cm. Your code must: 1) include a user-define function that performs a single period calculation, use the following function prototype: void pendulumPeriod(float length, float *period) 2) display to the monitor the length and period of the pendulums in table format with a header and units. 3) save the lengths and period of the pendulums to a file.arrow_forwardQuestion Write a program to determine the price for a portrait sitting. The price is determined by subjects in portraits, background chosen and sitting appointment day.The fee schedule is shown below. Fancy background and sitting appointment cost an extra 10 percent more than the base price. Subjects in Portrait Base Price 1 $100 2 $130 3 $150 4 $160 5 or more $165 Sample Output1: Enter the number of subjects in the portrait: 1 Do you want a fancy background (y/n)? y Do you want an appointment date (y/n)? y The price is: $120arrow_forward
- use visual basic Depreciation to a Salvage Value of 0 . For tax purposes an item may be depreciated over a period of several years, n . With the straight-line method of depreciation , each year the item dpreciates by 1/nth of it original value. with the double-declining-balance method of depreciation, each year the item depreciate by 2/nths of its value at the beginning of that year.(In the final year it is depreciated by its value at the beginning of the year. ) Write a program that performs the following tasks:(a) Request a description of the item, the year of purchase, the cost of the item, the number of years to be depreciated (estimated life), and the method of depreciation. The method of depreciation should be chosen by clicking on one of two buttons.(b) Display a year- by-year description of the depreciation. See Fig. 6.15 .arrow_forwardProblem Description Did you know that in lotteries, a 3-digit number with the same numbers in all digits like 777 will hit the jackpot in a casino? In the same manner, let's make a program that will test if a certain 3-digit number hits a jackpot or not by identifying if all the digits of a given number is the same as the second inputted number. If it is, print "Jackpot!"; else, print "Nah". Input A line containing two integers separated by a space. 777·7 Output A line containing a string. Jackpot! -USED JAVA PROGRAMMING LANGUAGEarrow_forwardIn Saudi Arabia, the Kudai Parking Area is a parking lot that is next to the Ajyad Police Station and close to the Power Plant. Kudai is a well-known parking space near Masjid al-Haram. After parking there, you can take a taxi to Masjid al-Haram for 10-15 Riyals for a 10-minute drive. The parking is usually heavily occupied, and the following formula is used to compute the parking lot uțilization: Percentage of Parking Lot Utilized - Number of lots occupied + Total number of lots Write a program that calculates the occupancy rate for each zone of a massive parking lot like Kudai. The program should start by asking for the number of zones in the parking lot. A loop should then iterate once for each zone. During each iteration, the loop should ask the user for the number of lots in the zone and the number of them that are occupied. After all the iterations, the program should display the number of lots the parking has, the number of them that are occupied, the number that is vacant, and…arrow_forward
- Homework write a program that will add the terms of an infinite geometric series. The program should read the first term (a) and the common ratio (r) for the series. It should the compute the sum in two ways: by formula (s=a/1-r), and by adding the individual terms until the answer agrees with the formula to 7 significant digits. The print the formula answer, the answer found by adding terms, and the number of terms that were added. Print the sums to at least ten places. Verify input with a while loop. Two real values are equal to n significant digits if the following condition is true: |a-b|<|a*10^-n| HELP ME FIX MY CODE comment in the picture. #include <iostream>#include <cmath>using namespace std; int main(){ int i = 1;double a, b, r, number, sumbyformula, sum2;cout<<"Enter a value of first term a: ";cin>>a;cout<<"Enter a value of ratio r: ";cin>>r;// Loop -1<r<1while(r>=1 and r<=-1){cout<< "Enter the number between -1 and 1…arrow_forwardHomework write a program that will add the terms of an infinite geometric series. The program should read the first term (a) and the common ratio (r) for the series. It should the compute the sum in two ways: by formula (s=a/1-r), and by adding the individual terms until the answer agrees with the formula to 7 significant digits. The print the formula answer, the answer found by adding terms, and the number of terms that were added. Print the sums to at least ten places. Verify input with a while loop. Two real values are equal to n significant digits if the following condition is true: |a-b|<|a*10^-n| Wrong test - this won't work if r is very near one. Try a=2, r=.99999 With smaller values of r, it is asking for too much precision. With a=2,r=.99, it is getting 10 significant digits. HELP ME FIX CODE. PLEASE USE MY CODE FIX #include <iostream>#include <cmath>using namespace std; int main(){ //declare variables int terms; double a, r, number, sumbyformula, sum2;…arrow_forwardA company of 20 employees wants to find the employee who made the highest commission so he/she can be paid a 10% bonus of the commission he/she earned for that month. The commission an employee makes is calculated by multiplying the sales amount by the commission rate. The commission rates are shown below: Sales Amount Commission Less Than 40000 No commission 40000 to 80000 inclusive 5% Greater than 80000 10% Write a program to: Prompt the user for each employee’s id (an integer value) and the sales amount For each employee, display the commission earned Display the total commission earned by all the employees Display the average commission earned by an employee Display the employee id, the commission and the bonus paid to the employee with the highest commission Must be written in c++, no arrays to be used, only use iostream libraryarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr