subject

You want to buy a new car, and you are thinking about two alternatives, car A and car B. You like both cars, and you are considering keeping whichever one you buy for many years to come. As a result, you want to evaluate the total cost of ownership of both cars over many years. Car A costs $20,000, whereas car B costs $30,000. Car A runs 25 miles with a gallon of gas, whereas car B runs 32 miles with a gallon of gas. You estimate that you will drive about 15,000 miles each year, and that gas price is going to be around $2.50 per gallon for the foreseeable future. The maintenance cost of car A is $1,300 in the first year, then that cost increases 15% (with compound growth) each year. The maintenance cost of car B is $1,000 in the first year, then that cost increases 10% (with compound growth) each year. Task 1. Write a method named compareCars(int years) that takes an integer number of years and prints a table with the total ownership cost of each car for each year, starting from year 0 which represents the time of purchase. The method will return the name of the most economical car on the last year. Note: For this problem, you are allowed to break the usual "no print statements inside a method" recommendation. Task 2. Using your method, answer this question: which car would you buy if you plan on keeping it for 5 years? 10 years? Discuss the results. Write your answer in a comment at the top of your code. Task 3. Answer this question: in a method, what is the difference between printing something and returning it? Write your answer in a comment at the top of your code.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:30
How can you know if the person or organization providing the information has the credentials and knowledge to speak on this topic? one clue is the type of web site it is--the domain name ".org" tells you that this site is run by a nonprofit organization.
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
Elements such as fonts colors visual structure graphics and the interface of a web page should complement each other to ensure blank
Answers: 3
question
Computers and Technology, 22.06.2019 23:00
In which part of a professional email should you try to be brief, but highly descriptive?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
You know the right answer?
You want to buy a new car, and you are thinking about two alternatives, car A and car B. You like bo...
Questions
question
Mathematics, 21.04.2021 03:50
question
Physics, 21.04.2021 03:50
question
Mathematics, 21.04.2021 03:50
question
Mathematics, 21.04.2021 03:50
Questions on the website: 13722360