Question: Java - I need help with my code I'm doing Calling methods but it seems to not compile here are my code import java.util.Scanner; public
Java - I need help with my code I'm doing Calling methods but it seems to not compile
here are my code
import java.util.Scanner;
public class bankAccountMethod
{ public static void main(String[] args) {
Scanner sc = new Scanner(System.in); String ch = "y"; do { System.out.println("Enter your first name"); String fName = sc.nextLine().toUpperCase(); System.out.println("Enter your last name"); String lName = sc.nextLine().toUpperCase(); System.out.println("Enter the type of account you want to open: Savings or Checking? "); String accType = sc.nextLine(); String checkingAc = ""; double checkingDeposit = 0; if (accType.equalsIgnoreCase("Savings")) { checkingAc = checkingAc + 0; } else if (accType.equalsIgnoreCase("Checking")) { int randomNum = (int) (Math.round(Math.random() * 10000) + 1); checkingAc = randomNum + " " + "Checking"; System.out.println("Enter the initial deposit in checking account: "); checkingDeposit = sc.nextDouble(); } String savingsAc = (Math.round(Math.random() * 10000) + 1) + " " + "Savings"; System.out.println("Enter the initial deposit in savings account: "); double savingDeposit = sc.nextDouble(); if (savingDeposit <= 100) { System.out.println("no accounts opened - initial deposit requirements not met."); } else { double interestRate; double balance = 0; if (savingDeposit <= 100) { System.out.println("Initial deposit in savings account must be over $100. "); balance = savingDeposit; } else if (savingDeposit > 100 && savingDeposit <= 500) { interestRate = 0.035; balance = savingDeposit + savingDeposit * interestRate; } else if (savingDeposit > 500 && savingDeposit <= 1000) { interestRate = 0.045; balance = savingDeposit + savingDeposit * interestRate; } else { interestRate = 0.05; balance = savingDeposit + savingDeposit * interestRate; } System.out.println("Name: " + fName + "," + lName); System.out.println( "Acct: " + checkingAc + "\t Acct: " + savingsAc + "\t Estimated Savings balance in 1 Year"); System.out.println("deposit: $" + checkingDeposit + "\t deposit: $" + savingDeposit + "\t $" + balance); if (Math.max(savingDeposit, checkingDeposit) == savingDeposit) { System.out.println("Savings account has the higher initial deposit"); } else { System.out.println("Checking account has the higher initial deposit"); } } System.out.print("Press Y to continue any other key to exit"); sc.nextLine(); ch = sc.next(); sc.nextLine(); } while (ch.equalsIgnoreCase("Y")); } public static double getInterestRate(double deposit) { double rate=0;
// checking deposit is less tha or equals to 100 if(deposit<=100){ rate = 0; } // checking deposit is less tha or equals to 500 else if(deposit<=500){ rate = 0.035; } // checking deposit is less tha or equals to 1000 else if(deposit<=1000){ rate = 0.045; } // otherwise else{ rate = 0.045; } return rate; } public static double calcFutureBalance(double deposit, double interest) { // this statement calculates the future balance balance = deposit * Math.pow(1 + interest, 12); } public static void main(String[] args) { System.out.println(calcFutureBalance(1000, 0.05)); }
public static void displayAccounts(String name, int ckAccount, double ckdeposit, int svAccount, double svdeposit, double interestRate) { double futureBalance; futureBalance = calcFutureBalance(svdeposit, interestRate); }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
