Question: import java.util.Locale; public class Interest { public static void main(String args[]) { double amount = 0.0; double principal = 1000; double rate = 0.05; System.out.println(Year
import java.util.Locale; public class Interest { public static void main(String args[]) { double amount = 0.0; double principal = 1000; double rate = 0.05; System.out.println("Year Amount on deposit"); for(int year=1; year<=10; year++) { amount = principal * Math.pow((1+rate),year); System.out.printf("%4s ",year); amount = Math.round(amount * 100.0)/100.0; System.out.printf(Locale.US, "%,19.2f %n",amount); } } }
Rewrite this code using a "while" loop instead of a "for" loop.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
