سؤال 4.7 من الكتاب:
(Financial application: computing future tuition) Suppose that the tuition for a
university is $10,000 this year and increases 5% every year. Write a program that
computes the tuition in ten years and the total cost of four years’ worth of tuition
starting ten years from now.
الحل:
كود PHP:
double tuition=(10000);
int year=1;
while (year<=10){
tuition=((tuition *0.05)+tuition);
if (year==4){
System.out.printf("The total cost of four years: $%.2f\n",tuition);}
if (year==10){
System.out.printf("The Tuition in 10 years is: $%.2f\n",tuition);}
year++;}