I'm dragging this question over from another website from a recommendation.
I'm writing a program in BlueJ that gets the starting price of Tuition in the first year ($8000) and for each year afterwards the price raises by 4.7%.
public class Tuition
{
public static void main(String[] args)
{
int years;
final double Tuition = 8000;
double Price;
years = 1;
System.out.printf("%15s %15s\n", "Year", "Tuition Price");
while (years <= 4)
{
Price = years + 8000;
System.out.printf("%15d %15.1f\n", years, Price);
years ++;
}
}
}
Now obviously the only line (I think) I need help with is
Price = years + 8000;
Because right now with the way I have it it just adds 8000 to every year. (8001 for year one, 8002 for year two, etc.)
What's the equation I would write in that line to get the yearly 4.7% increase? Thanks.
How about
Edit: if you want to avoid "^", initiate before the loop with
then, inside the loop, replace
with
The rest of the code stays unchanged.