Purpose: Using multi-tier (layers) architecture, develop an object-oriented version of a procedural application to share classes. The following shows the code for the future value application. Then, modify the application: import java.text.NumberFormat; import java.util.Scanner; public class FutureValueCalculator public static void main(String[] args) { // TODO Auto-generated method stub //display a welcome message System.out.println("Welcome to the Future Value Calculator"); System.out.println(); Scanner sc = new Scanner(System.in); String choice = "Y"; while (choice.equalsignoreCase("Y")) ( // get input from the user System.out.print("Enter monthly investment: "); double monthlyInvestment - Double.parse Double(sc.nextLine()); System.out.print("Enter yearly interest rate: "); double yearlyinterestRate = Double.parseDouble(sc.nextLine()); System.out.print("Enter number of years: "); int years = Integer.parseInt(sc.nextLine()); //convert yearly value to monthly value double monthlyInterest Rate = yearlyinterestRate / 12 /100; int months = years. 12; //calculate the future value 1
double futureValue 0; int i = 1; while(ica months) futureValue = future Value - monthlyInvestment: double monthlyInterestAmount = future Value monthlyInterestRate; futureValue = futureValue + monthlyinterestAmount; i 1+1 * ) //Format and display the result System.out.println("Future Value: NumberFormat.getCurrencyInstance().format(futureValue): System.out.println(); //see if the user wants to continue System.out.print("Continue? (v/n): "); choice = sc.nextLine(); System.out.println(); System.out.println("byel"); Output: Welcome to the Future Value Calculator Enter monthly investment: 1ee Enter yearly interest rate: 3 Enter number of years: 3 Future Value: $3,771.46 Continue? [y/n): Y Enter monthly investment: 120 Enter yearly interest rate: 3 Enter number of years; 3 Future Value: $4,525.75 Continue? (y/n): n bye!
Purpose: Using multi-tier (layers) architecture, develop an object-oriented version of a procedural application to share
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Purpose: Using multi-tier (layers) architecture, develop an object-oriented version of a procedural application to share
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!