Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to add a helper application to the driver application that truncates the

ID: 3641217 • 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.

/* 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; iteration
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote