Total members 11894 |It is currently Sun Nov 24, 2024 6:39 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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);
}
}
 





Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

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



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  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
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com