Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Jul 2017 |
Last Sign in: | 210 Weeks Ago, 6 Days Ago |
Questions Answered: | 15833 |
Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Suppose that the tuition for a university is $5,500 this year and
increases 2% every year. In one year, the tuition will be $5,610, the
next $5,722.20, etc. Write a program that computes the tuition on the
nth year and the total cost of four years' worth of tuition after that
year.
HINT: if today's tuition is $5,500, at a 2% increase, the tuition next
year will be:
5610 = 5500 * (1.02)
and the next year:
5722.20 = 5610 * (1.02)
For example:
given an initial tuition of $6,000 at 2% a year for 15 years:
the program must print:
Given today's tuition: 6000.00, at a rate of 2.00% tuition in 15 years
is 8075.21 The four-year tuition in 15 years is 33282.85
given an initial tuition of $5,500 at 5% a year for 10 years:
the program must print:
Given today's tuition: 5500.00, at a rate of 5.00% tuition in 10 years
is 8958.92 The four-year tuition in 10 years is 38614.07
============================================================
Write a public class call FutureTuition
class FutureTuition has only one method called run.
specs for run:
name: run
returns: nothing
arguments: a double called initialTuition, a double called rate, and
an int called years (so 3 arguments: two doubles and one int).
what it does: it prints a) the tuition after that number of years and
given that rate, and b) the total cost of four years' worth of tuition
after that number of years.
please notice how run formats its results. The amounts only display
two digits to the right of the decimal point and the decimal point
itself is always on the same column (as long as the initial tuition is
less than 100,000). Look at run(6,80,15) below. It has to display
small and large numbers but they are always aligned.
Examples:
run(10000,2,10)
year tuition
1 10200.00
2 10404.00
3 10612.08
4 10824.32
5 11040.81
6 11261.62
7 11486.86
8 11716.59
9 11950.93
10 12189.94
Given today's tuition: 10000.00, at a rate of 2.00% tuition in 10 years is 12189.94
The four-year tuition in 10 years is 50242.17
run(6000,5,15)
year tuition
1 6300.00
2 6615.00
3 6945.75
4 7293.04
5 7657.69
6 8040.57
7 8442.60
8 8864.73
9 9307.97
10 9773.37
11 10262.04
12 10775.14
13 11313.89
14 11879.59
15 12473.57
Given today's tuition: 6000.00, at a rate of 5.00% tuition in 15 years is 12473.57
The four-year tuition in 15 years is 53762.64
run(6,80,15)
year tuition
1 10.80
2 19.44
3 34.99
4 62.99
5 113.37
6 204.07
7 367.33
8 661.20
9 1190.16
10 2142.28
11 3856.10
12 6940.99
13 12493.78
14 22488.80
15 40479.84
Given today's tuition: 6.00, at a rate of 80.00% tuition in 15 years is 40479.84
The four-year tuition in 15 years is 480576.70
run(100000,2,10)
year tuition
1 102000.00
2 104040.00
3 106120.80
4 108243.22
5 110408.08
6 112616.24
7 114868.57
8 117165.94
9 119509.26
10 121899.44
Given today's tuition: 100000.00, at a rate of 2.00% tuition in 10 years is 121899.44
The four-year tuition in 10 years is 502421.72
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly