Hey guys i am in need of some desperate help with a program i'm trying to create. Basically it's a program that has 3 options. Selecting "A" will prompt the user for 3 values. An Initial Deposit Amount, Rate of interest per year and Amount to be deposited each month.
Once the user has supplied the initial deposit amount and interest rate for the account as well as the monthly deposit amount, the program should then proceed to calculate the new balance for the account including interest earned over a six month period.
So far i have the basic outline out and i have the 3 input values but for the 2nd value "Enter the annual interest rate as a percentage" i don't know how to code it to it says for example 6.0 instead of 60.
And how would i do the calculation for the initial deposit amount, monthly deposit amount and new balance for the account including interest? I'm new to java programming so i'm still a bit unsure. Any help would be greatly appreciated. Here is my program code,
Once the user has supplied the initial deposit amount and interest rate for the account as well as the monthly deposit amount, the program should then proceed to calculate the new balance for the account including interest earned over a six month period.
So far i have the basic outline out and i have the 3 input values but for the 2nd value "Enter the annual interest rate as a percentage" i don't know how to code it to it says for example 6.0 instead of 60.
And how would i do the calculation for the initial deposit amount, monthly deposit amount and new balance for the account including interest? I'm new to java programming so i'm still a bit unsure. Any help would be greatly appreciated. Here is my program code,
Code:
import java.util.Scanner;
public class MenuDrivenProgram
{
private static Scanner s = new Scanner(System.in);
public static void main(String[] args)
{
String inputLine;
char option = ' ';
do
{
//Prints the line allowing you to select one of the valid options
printMenu();
System.out.printf("Please select a valid option: ");
inputLine = s.nextLine();
//Prints out an error message if length is equal to 1
if (inputLine.length() != 1)
{
System.out.printf("Error! You did not select a valid option!\n");
System.out.printf("Please try again\n\n");
}
else
{
option = inputLine.charAt(0);
option = Character.toUpperCase(option);
switch (option)
{
//Brings up the InvestmentReport menu
case 'A':
InvestmentReport();
break;
//Brings up the RainfallReport menu
case 'B':
RainfallReport();
break;
//Exits the program with a goodbye message
case 'X':
System.out.printf("Exiting the program - goodbye...\n\n");
break;
//Errors out if keyed in value isn't a valid menu option
default:
System.out.printf("Error!" +
"\"%c\" is not a valid menu option!\n\n",
option);
}
}
} while (option != 'X');
}
//This prints the main menu and let's you choose between 3 different options. InvestmentReport, RainfallReport and Exiting the program
public static void printMenu()
{
System.out.printf("*************** Assignment 2 Menu ***************\n\n");
System.out.printf("\tA. InvestmentReport.\n");
System.out.printf("\tB. RainfallReport.\n");
System.out.printf("\tX. Exit the program\n\n");
System.out.printf("*************************************************\n\n");
}
public static void InvestmentReport()
{
System.out.printf("*** Investment Report stub ***\n");
// This is where your Part A solution goes
System.out.printf("*************** InvestmentReport Menu ***************\n\n");
Scanner console=new Scanner(System.in);
int deposit, monthly;
double interest;
System.out.println ("Enter your initial deposit amount in dollars\n");
deposit = console.nextInt();
System.out.println ("Enter the annual interest rate as a percentage (eg. 6.0)\n");
interest = console.nextInt();
System.out.println ("Enter your monthly deposit amount in dollars\n");
monthly = console.nextInt();
System.out.println ("Savings growth over the next 6 months:\n");
System.out.println ("Balance after first month:\n");
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after second month:\n");
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after third month:\n");
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after fourth month:\n");
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after fifth month:\n");
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after sixth month:\n");
System.out.println ("Interest earned for this month:\n");
}
public static void RainfallReport()
{
System.out.printf("*** Rainfall Report stub ***\n");
// This is where your Part B solution goes
System.out.printf("*************** RainfallReport Menu ***************\n\n");
Scanner sc = new Scanner(System.in);
double[] fall = new double[7];
for (int i = 0 ; i < 7 ; i++)
{
System.out.print("Enter RainFall Measure In Millimetres: " + (i+1) + ": ");
fall[i] = sc.nextDouble();
}
System.out.println("R.Fall Reverse Order ");
for ( int i = 0; i>=7 ; i--)
{
System.out.println(fall[i]);
}
}
}