Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

for loop help

$
0
0
I just started learning loops in java and given this exercise: Suppose that the tuition for a university is $40,000 this year and tuition increases 3% every year. Write a program that uses a for loop to compute the tution in 10 years.

public class Exercise2{
 public static void main(String[] args){
 int sum=0;
 int fee;
 
  //Prints 10 statements
  for(int i=1; i<11; i++){
  for(fee=1; fee<11; fee=(40000*(3/100)))  //Calculates the fees
  fee++;
  System.out.println("The tution fee for year "+i+" is "+fee); //Results
  
   }


  }
 }


This is my code so far and now I'm stuck on how to use the for loop to calculate the fee each year. Help?

Its not working correctly I need help

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>