1) Calculate interest payable 2) Calculate principle require to earn interest 3) Calculate time required to earn interest 4) Exit program Please enter your choice <1-4>:

This output is correct.

But the problems are in my next few statements. To make it short, I have two problems with my java program. I am troubled as on how do I write the code that allows me to go back to my program menu after I had made a selection

**[ Problem 1]**! When I chose option 1 ( which is this ),

1) Calculate interest payable 2) Calculate principle require to earn interest 3) Calculate time required to earn interest 4) Exit program Please enter your choice <1-4>: 1 Enter principle amount in $: 20000 Enter interest rate in %: 5 Enter period (time) in days: 10 Interest earned is $27.397260273972602

it stops and I was not directed back to my program's menu for another selection. Did I miss out on any code for my program?

On line 34 of my output, which is the formula for calculating the bank interest incurred on any amount, I was confused.

1) Calculate interest payable 2) Calculate principle require to earn interest 3) Calculate time required to earn interest 4) Exit program Please enter your choice <1-4>: 2 Enter interest amount to be earned: 22000 Enter interest rate in %: 500 Enter period(time) in days: 50 You need a principle of $0.0

How come the calculation is $0 of principle when at line 34, it clearly states the formula that is being used to calculate the principle needed, which is

Formula:

interestEarned=principle*(rate/100)*(days/365);

**(Problem 2)**

For choice 1 of my menu, I have no problems getting the figure. But, for choice 2 and 3 of my program, the figure is $0.

Are there any errors with my program ? Below are my full codes for the program to help you guys understand better.

import java.util.*; public class BankInterest { static Scanner input = new Scanner(System.in); Scanner scanner = new Scanner(System.in); static double principle, rate, days, interestEarned, choice; public static void main(String[] args) { display_menu(); }//end of main static void display_menu() { System.out.println("1) Calculate interest payable"); System.out.println("2) Calculate principle require to earn interest"); System.out.println("3) Calculate time required to earn interest"); System.out.println("4) Exit program"); //Prompt for choice System.out.println("Please enter your choice <1-4>:"); Scanner q = new Scanner(System.in); switch (q.nextInt()) { case 1: System.out.println("Enter principle amount in $:"); principle=input.nextDouble(); System.out.println("Enter interest rate in %:"); rate=input.nextDouble(); System.out.println("Enter period (time) in days:"); days=input.nextDouble(); //Calculation interestEarned=principle*(rate/100)*(days/365); System.out.println("Interest earned is $"+ interestEarned); break; case 2: System.out.println(" Enter interest amount to be earned:"); interestEarned=input.nextDouble(); System.out.println("Enter interest rate in %:"); rate=input.nextDouble(); System.out.println(" Enter period(time) in days:"); days=input.nextDouble(); //Calculation interestEarned=principle*(rate/100)*(days/365); System.out.println("You need a principle of $"+ interestEarned); break; case 3: System.out.println("Enter interest amount to be earned:"); interestEarned=input.nextDouble(); System.out.println("Enter interest rate in %:"); rate=input.nextDouble(); System.out.println("Enter principle amount in $:"); principle=input.nextDouble(); //Calculation interestEarned=principle*(rate/100)*(days/365); System.out.println("Days required to earn interest is "+days); days=input.nextDouble(); break; case 4: System.out.println("Thank you for using the Bank Interest Program, we hope to see you again."); break; default: System.err.println ( "Invalid choice. Please enter it again:" ); choice=input.nextInt(); break; } } public BankInterest() { Scanner in = new Scanner(System.in); display_menu(); switch (in.nextInt()) { case 1: System.out.println ( "You picked option 1" ); display_menu(); break; case 2: System.out.println ( "You picked option 2" ); display_menu(); break; case 3: System.out.println ( "You picked option 3" ); display_menu(); break; default: System.err.println ( "Unrecognized option" ); break; } } public static void main1 (String[]args) { display_menu(); } }