I need to add a helper application to the driver application that truncates the
ID: 3641233 • Letter: I
Question
I need to add a helper application to the driver application that truncates the digits to two numbers instead of rounding them up. I should have two class files and two java files for this program when it is completed./* BankAccount.java
Programmer: Aaron Monhollen
Date: March 29, 2012
Purpose: To calculate an initial invest with interest compounded for ten
years, daily, monthly, and yearly.
*/
import java.util.*;
public class BankAccount
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
double initialBalance;
double interestRate;
double newBalance; // after 10 years
char answer; // sentinel to repeat or end program
int iteration; // loop counter
do // repeat entire program if user says yes
{
System.out.println("Please enter an initial balance "
+ "(dollars.cents):");
initialBalance = keyboard.nextDouble();
System.out.println("Please enter an interest rate in percent "
+ "(e.g. 5.25):");
interestRate = keyboard.nextDouble();
// Display initial information before calculations
System.out.println("In ten years an initial balance of $"
+ initialBalance);
System.out.println("at an interest rate of "
+ interestRate + "% will be worth");
newBalance = initialBalance;
// initialize before entering annual compounding loop
for(iteration =1; iteration <= 10; ++iteration) // compound annually
newBalance = newBalance + (interestRate/100) * newBalance;
System.out.println("$" + newBalance + " compounded annually");
newBalance = initialBalance;
// initialize before entering monthly compounding loop
for(iteration =1; iteration <= 120; ++iteration) // compound monthly
newBalance = newBalance + (interestRate/12) * (newBalance/100);
System.out.println("$" + newBalance + " compounded monthly");
newBalance = initialBalance;
// initialize before entering daily compounding loop
for(iteration =1; iteration <= 3650; ++iteration) // compound daily
newBalance = newBalance + (interestRate/365) * (newBalance/100);
System.out.println("$" + newBalance + " compounded daily");
System.out.println(""); // empty line for better readability
System.out.println("Do you want to do it again?");
System.out.println("Enter y for yes or n for no.");
answer = keyboard.next().charAt(0);
}while ((answer == 'y') || (answer == 'Y'));
}
}
Explanation / Answer
package bank; /* BankAccount.java Programmer: Aaron Monhollen Date: March 29, 2012 Purpose: To calculate an initial invest with interest compounded for ten years, daily, monthly, and yearly. */ import java.text.DecimalFormat; import java.util.*; public class BankAccount { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); double initialBalance; double interestRate; double newBalance; // after 10 years char answer; // sentinel to repeat or end program int iteration; // loop counter do // repeat entire program if user says yes { System.out.println("Please enter an initial balance " + "(dollars.cents):"); initialBalance = keyboard.nextDouble(); System.out.println("Please enter an interest rate in percent " + "(e.g. 5.25):"); interestRate = keyboard.nextDouble(); // Display initial information before calculations System.out.println("In ten years an initial balance of $" + initialBalance); System.out.println("at an interest rate of " + interestRate + "% will be worth"); newBalance = initialBalance; // initialize before entering annual compounding loop for (iteration = 1; iterationRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.