Okay, so I have 2 classes (Investment and Project4)
This program is designed to display 5 menu options.
The first menu option asks the user for a starting balance and an interest rate
The second menu option asks the user for the number of years they want to invest and the number of times they want the value compounded each year.
* Here is where my problem comes in*
The third menu is supposed to display these 4 variables(principal, interestRate, numberOfYears, numberOfTimes)
My investment class handles all the calculations for which the algorithm is
principal * Math.pow((1 + interestRate / numberOfTimes), (numberOfYears * numberOfTimes));
Here is the code from my Project4 class which has my main in it. I am on the method named menu3() and I don't know how to incorporate the above values into this method mainly because it has to go through the Investment class to calculate the futureValue and then go through this method that is not the main method.
/**
* Class Name : Project4<br>
* Class Purpose: Display Menu options for a user to select and display corresponding data in the chosen menu. Continues until the user ends program
import java.util.Scanner; import java.text.DecimalFormat; public class Project4 private static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { Project4 app = new Project4(); //Display all Menu options app.displayMenus(); //Asks user to pick a menu option System.out.println("Please choose a menu option:"); int option = keyboard.nextInt(); while(option >=1 || option <= 5) { if(option == 1) { app.menu1(); app.displayMenus(); System.out.println("Please choose a menu option:"); option = keyboard.nextInt(); } if(option == 2) { app.menu2(); app.displayMenus(); System.out.println("Please choose a menu option:"); option = keyboard.nextInt(); } else if(option == 3) { app.menu3(); System.out.println("Please choose a menu option:"); option = keyboard.nextInt(); } else if(option == 4) { System.out.println("Under construction"); app.displayMenus(); System.out.println("Please choose a menu option:"); option = keyboard.nextInt(); } else if(option == 5) { System.out.println("Are you sure you want to exit? (y/n)"); String answer = keyboard.nextLine(); if(answer.equalsIgnoreCase("y")) { System.out.println("End of program"); break; } else if(answer.equalsIgnoreCase("n")) { app.displayMenus(); System.out.println("Please choose a menu option:"); option = keyboard.nextInt(); } } } } public void displayMenus() { System.out.println("1 - Enter starting balance and interest rate." + " \n2 - Enter the number of years and the number of times." + " \n3 - Display the balance schedule." + " \n4 - Display the bar graph." + " \n5 - Exit."); } public void menu1() { System.out.println("What is the starting balance (value from 1 to 10,000)."); double principal = keyboard.nextDouble(); while(principal < 1 || principal > 10000) { System.out.println("Please enter a value between 1 and 10,000"); principal = keyboard.nextDouble(); } System.out.println("What is the interest rate (value from 0 to 1)"); double interestRate = keyboard.nextDouble(); while(interestRate < 0 || interestRate > 1) { System.out.println("Please enter a value between 0 and 1"); interestRate = keyboard.nextDouble(); } } public void menu2() { System.out.println("How many years do you plan to invest? (1-20)"); int numberOfYears = keyboard.nextInt(); while(numberOfYears < 1 || numberOfYears > 20) { System.out.println("Please enter a number between 1 and 20."); numberOfYears = keyboard.nextInt(); } System.out.println("How many times per year? (1-12)"); int numberOfTimes = keyboard.nextInt(); while(numberOfTimes < 1 || numberOfTimes > 12) { System.out.println("Please enter a number between 1 and 12."); numberOfTimes = keyboard.nextInt(); } } public void menu3(double principal, double interestRate, int numberOfYears, int numberOfTimes) { System.out.println("If you invested " + principal + " in a bank account paying " + interestRate + " for " + numberOfYears + "years, \ncompounded " + numberOfTimes + "times per year, then your balance will be:"); } public void menu4() { } }