Concept explainers
You have just purchased a stereo system that cost $1,000 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 $1,000 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 of interest and the size of the debt after each month. (Your final program need not output the monthly amount of interest paid and remaining debt, but you may want to write a preliminary version of the program that does output these values.) Use a variable to count the number of loop iterations and hence the number of months until the debt is zero. You may want to use other variables as well. The last payment may be less than $50. Do not forget the interest on the last payment. If you owe $50, then your monthly payment of $50 will not pay off your debt, although it will come close. One month’s interest on $50 is only 75 cents.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Installation of a Shopee Billboard Max. score: 100 You are installing a billboard and want it to be at the maximum height. The billboard will have two steel supports, one on each side. The height of each steel bracket must be equal. You have a number of rebar rods that can be welded together. For example, if the bars are of length 1, 2, and 3, they can be welded together to form a length of 6 brackets. Return the maximum possible installation height of the billboard. Return 0 if the billboard cannot be installed.arrow_forwardScenario As you surely know, due to some astronomical reasons, years may be leap or common. The former are 366 days long, while the latter are 365 days long. Since the introduction of the Gregorian calendar (in 1582), the following rule is used to determine the kind of year: if the year number isn't divisible by four, it's a common year, otherwise, if the year number isn't divisible by 100, it's a leap year. otherwise, if the year number isn't divisible by 400, it's a common year. otherwise, it's a leap year. none of the above year int(input("enter the year")) if (year%4 1-0) and (year%400 -0) or (year % 1000): print (year is common year") else: print(year, is leap year") year= int(input ("enter the year")) if (years !-0) or (year480 1-0) and (year % 1001-0): print(year is common year") else: print(year, "is leap year") D year= int(input("enter the year"))arrow_forwardA basic safe type of investment is an annuity: one makes monthly deposits of size P for n months at a fixed annual interest rate r, and at maturity collects the amount 12P n r ((₁ + 2)² − ¹) 12 r (This is not the definition of annuity that you may be familiar with, but the calculation is part of any accumulation of funds over time.) Say you want to create an annuity for a term of 300 months and final value of 1,000,000 dollars. Using nlsolve, make a table of the interest rate you will need to get for each of the different contribution values P 500 + 50k, k = 0, ..., 10. - Hint: if you write a function for the value of annuity, or the difference between this value and one million dollars with several arguments (P, r, n), you can then create a new function of just the one variabler for each value of P in a loop. The table and pretty tables approach used in homework 2 will be helpful here.arrow_forward
- 1. You need to take a trip by car to another town that you have never visited before. Therefore, you are studying a map to determine the shortest route to your destination. Depending on which route you choose, there are five other towns (call them A, B, C, D, E) that you might pass through on the way. The map shows the mileage along each road that directly connects two towns without any intervening towns. These numbers are summarized in the following table, where a dash indicates that there is no road directly connecting these two towns without going through any other towns. Miles between Adjacent Towns Town A B C D E Destination Origin 40 60 50 A 10 65 B 10 20 55 40 20 50 65 55 10 60 E 40 50 10 80 Formulate this problem as a shortest-route problem and find the shortest path.arrow_forwardJAVA Based Prgmarrow_forwardA flight of stairs has 10 steps numbered 1 to 10 as shown in the figure below. i. How many ways could you climb up the set of stairs, assuming that you can skip any number of stairs with each step, but you must end on step 10 and you can only go up, never down and never remaining on the same step. ii. How many ways could you climb up the set of stairs, assuming you take exactly 4 steps. Again, your staircase climb ends on step 10. JAlthough there are different ways in which you could solve this problem, model the problem as a balls and bins problem for full credit.arrow_forward
- At QT Sugar factory the amounts which go into bag of sugar are supposed to be normally distributed with mean 36 kg and standard deviation 0.1 kg. Once every 30 minutes a bag is selected from the production line, and its contents are noted precisely. If the amount of the bag goes below 35.8 kg or above 36.2 kg, then the bag will be declared out of control. a) If the process is in control, meaning u = 36 kg and o= 0.1 kg, find the probability that the bag will be declared out of control. b) In the situation of (a), find the probability that the number of bag found out of control in an eight-hour day (16 inspections) will be zero. c) In the situation of (a), find the probability that the number of bag found out control in an eight- hour day (16 inspections) will be exactly one. d) If the process shifts so that u =37 kg and o=0.4 kg find the probability that a bag will be declared out of control.arrow_forwardCraps is a single player dice game, that proceeds as follows:1. the player rolls 2 six-sided dice once if the total is 7 or 11, the player wins if the total is 2, 3 or 12, the player loses otherwise, the game continues, ... see 2 ... 2. the player the continues to roll the dice repeatedly, until ... the total is the same as the original total (from 1), in which case the player wins the total is 7, in which case the player loses Write a function craps using Python that simulates a single game of craps (may be many rolls) and returns 1 if the player wins and 0 otherwise. Sample results examples: >> import random>>> random.seed(0)>>> craps()0 >>> random.seed(1)>>> craps()1 >>> random.seed(2)>>> craps()0 >>> [ (i,random.seed(i),craps()) for i in range(20)][(0, None, 0), (1, None, 1), (2, None, 0), (3, None, 1), (4, None, 0), (5, None,1), (6, None, 0), (7, None, 1), (8, None, 0), (9, None, 0), (10,…arrow_forwardYou have just started a sales job in adepartment store. Your pay consists of a base salary and a commission. The base salaryis $5,000. The scheme shown below is used to determine the commission rate. Note that this is a graduated rate. The rate for the first $5,000 is at 6%, the next$5000 is at 8%, and the rest is at 10%. If your sales amounts to $25,000, the commissionis 5,000 * 6% + 5,000 * 8% + 15,000 * 10% = 2,200. Your goal is toearn $30,000 a year. Write a program to find the minimum sales you have to generatein order to make $30,000.arrow_forward
- The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. Table 4.2 shows the rates for 2009. If you are, say, single with a taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%. So, your tax is $1,082.50. TABLE 4.2 2009 U.S. Federal Personal Tax Rates Marginal Tax Rate 10% 15% 25% 28% 33% 35% Single $0-$8,350 $8,351-$33.950 $33,951-$82,250 $82,251 - $171,550 $171,551-$372,950 $372,951+ Married Filing Jointly $0-$16,700 $16,701-$67,900 $67.901-$137,050 $137,051 - $208,850 $208,851-$372,950 $372,951+ Married Filing Separately $0-$8,350 $8,351-$33,950 $33,951 - $68,525 $68,526-$104,425 $104,426-$186,475 $186,476+ Head of Household $0-$11,950 $11,951-$45,500 $45,501-$117,450 $117.451-$190,200 $190,201-$372,950 $372.951+ You are to write a program to…arrow_forwardUsing C Languagearrow_forwardA retail store has a preferred customer plan where customers can earn discounts on all their purchases. The amount of a customer’s discount is determined by the amount of the customer’s cumulative purchases in the store as follows: • When a preferred customer spends $500, he or she gets a 5 percent discount on all future purchases. • When a preferred customer spends $1,000, he or she gets a 6 percent discount on all future purchases. • When a preferred customer spends $1,500, he or she gets a 7 percent discount on all future purchases. • When a preferred customer spends $2,000 or more, he or she gets a 10 percent discount on all future purchases. Design a class named PreferredCustomer, which is derived from the Customer class you created in Programming Problem 4. The PreferredCustomer class should have properties for the amount of the customer’s purchases and the customer’s discount level. Demonstrate the class in a simple application.arrow_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