Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

loop to compute the tuition in ten years

Wed Feb 11, 2009 9:09 pm

Simple While Java Loop Example:
Example of Java loops usage for writing a java program that uses a loop to compute the tuition in ten years and it increases 5% every year. While loop is used and at each iteration the number of year is increased, the loop counter is increased and finally the tuition is creased by 5%.
Code:
import java.util.Scanner;

public class Exercise4_7 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);


        int tuition = 10000;
        int years = 1;
        int count = 1;{

        }
        while (count <= 10) {
          
           tuition
+=(tuition*.05);
           years++;
           count++;
        }
        System.out.println("The tuition" + tuition + "is" + years);
}
}
 




Re: Need help with a loop

Sat Feb 14, 2009 10:17 am

Code:
        while (count <= 10) {
         
           tuition+=(tuition*.05);
           years++;
           count++;
        }



Post a reply
  Related Posts  to : loop to compute the tuition in ten years
 Validation of php drop down menu of months,days and years     -  
 compute binomial coefficients     -  
 compute area of the circle.     -  
 compute number of files in directory     -  
 Compute FFT (Fourier Transform) in ITK for a 2d image     -  
 Program to compute commission using two methods     -  
 compute maximum and minimum values, also scaling factor.     -  
 While loop     -  
 do while loop and for loop C++ example help.     -  
 C++ While loop     -  

Topic Tags

Java Loops, Java Basics