Instructions
Requirements and Specifications
Source Code
import java.util.Scanner;
public class Tables {
// Constants
private static final Scanner CONSOLE = new Scanner(System.in);
// Entry point of the program
public static void main(String[] args) {
System.out.println("UTSA - Summer 2021 - CS1083 - Prj 1 - written by YOURNAME - ABC123");
System.out.println();
// Ask for the inputs for calculation
System.out.print("Enter original amount: ");
double principalAmount = CONSOLE.nextDouble();
System.out.print("Enter annual interest rate: ");
double annualInterestRate = CONSOLE.nextDouble();
System.out.print("Enter years: ");
int years = CONSOLE.nextInt();
// Calculate the annual interest to pay
System.out.println();
System.out.println("Year\tValue");
for (int year = 0; year <= years; year++) {
double value = principalAmount * (1 + year * annualInterestRate / 100);
System.out.print(year + "\t");
System.out.printf("%.2f", value);
System.out.println();
}
System.out.println();
// Ask for the inputs for calculation
System.out.print("Enter original amount: ");
principalAmount = CONSOLE.nextDouble();
System.out.print("Enter annual interest rate: ");
annualInterestRate = CONSOLE.nextDouble();
System.out.print("Enter years: ");
years = CONSOLE.nextInt();
// Calculate the quarterly interest to pay
System.out.println();
System.out.println("Year\tQ1 Value\tQ2 Value\tQ3 Value\tQ4 Values");
for (int year = 1; year <= years; year++) {
System.out.print(year + "\t");
// Calculate each quarter for the year
for (int quarter = 1; quarter <= 4; quarter++) {
double value = principalAmount * (1 + (year - 1 + quarter / 4.0) * annualInterestRate / 100);
System.out.printf("%.2f\t\t", value);
}
System.out.println();
}
}
}