Question

# 2). Question with methods use scanner (Using Java): You are going to invest the amount, then...

2). Question with methods use scanner (Using Java):

You are going to invest the amount, then you going to compute that amount with annual interest rate.

1) Prompt the user to enter student id, student name, student major

2) Declare variables consistent with names that you are prompting and relate them to the scanner

3) Declare the amount invested in college, prompt the user to ask for amount and declare variable and scanner to input

4) Declare the annual interest rate, prompt the user to ask for annual rate and declare variable and scanner to input

5) Declare variable of monthly interest

6) Calculate the above variable where annual interest rate is divided by 1200.0

7) Display Student Id, Student Name, Student Major

8) Underneath that display Years and Future value

9) Underneath that create for loop where i is equal to 1; then i< number of months you want?; i++

10) Inside of brackets of for loop create double variable which is equal to method name (any name you want to called)( investment amount, monthly interest rate, i)

11) Display : System.out.printf("%-5d %12.2f\n", i, futureValue);

12) Create public static double method (give any name you want) which should match with the name in main method outside of main method with parameters: investment Amount,monthly interest rate, years.

13) Inside of method return calculation investment amount * Math.pow(1 + monthly interest rate, years * 12);

``````import java.util.Scanner;
/* Java class */
public class Main{

/* calculate investment value after some years with monthly compounding*/
public static double monthly_compound(double amount, double monthly_interest_rate, int years){
return (int)((amount * Math.pow(1 + monthly_interest_rate, years * 12)*100))/100.0;
}

/* this function clculates future value of a amount after i month */
public double find_futureValue(double amount,double  monthly_interest_rate, int i){
for(int j = 1; j <= i; j++)
amount += amount * monthly_interest_rate;
return amount;
}

public static void main(String[] args){
/* declare object */
Main obj = new Main();
Scanner sc = new Scanner(System.in);

/* declare variables */
String id, name, major;
int amount, i;
double interest_rate, monthly_interest_rate;

/* Take input of id, name and major */
System.out.print("Enter the student id: ");
id = sc.nextLine();
System.out.print("Enter the name: ");
name = sc.nextLine();
System.out.print("Enter the major: ");
major = sc.nextLine();

/* take input of amount */
System.out.print("Enter the amount invested: ");
amount = sc.nextInt();

/* take input of interest rate */
System.out.print("Enter the annual interest rate: ");
interest_rate = sc.nextDouble();

/* calculate monthly interest */
monthly_interest_rate = interest_rate/1200;

/* display student information */
System.out.println("Student ID: "+id);
System.out.println("Student Name: "+name);
System.out.println("Student Major: "+major);

/* calculate the future value */
System.out.print("\n");
for(i = 1; i< 13; i++){
double futureValue = obj.find_futureValue(amount, monthly_interest_rate, i);
System.out.printf("After month %-5d investment value  %12.2f\n", i, futureValue);
}
int years = 5;
System.out.println("\nAfter "+years+" years, with monthly compounding the investment value = "+
obj.monthly_compound(amount, monthly_interest_rate, years));
}
}``````

___________________________________________________________________

___________________________________________________________________

``````Enter the student id: joh123
Enter the name: John Hopkins
Enter the major: CSE
Enter the amount invested: 10000
Enter the annual interest rate: 10
Student ID: joh123
Student Name: John Hopkins
Student Major: CSE

After month 1     investment value      10083.33
After month 2     investment value      10167.36
After month 3     investment value      10252.09
After month 4     investment value      10337.52
After month 5     investment value      10423.67
After month 6     investment value      10510.53
After month 7     investment value      10598.12
After month 8     investment value      10686.44
After month 9     investment value      10775.49
After month 10    investment value      10865.29
After month 11    investment value      10955.83
After month 12    investment value      11047.13

After 5 years, with monthly compounding the investment value = 16453.08``````

___________________________________________________________________

#### Earn Coins

Coins can be redeemed for fabulous gifts.

##### Need Online Homework Help?

Most questions answered within 1 hours.

##### Active Questions
• describe the type of empowering leadership perspective Denise Morrison used as ceo of Campbell soup company
• (1) How much does a sleeping bag cost? Let's say you want a sleeping bag that...
• Suppose you were asked to test some code for possible issues handling exceptions. Describe briefly how...
• A mineral exploration firm is formed with enough capital to finance 9 ventures. The probability of...
• Do you consider yourself an internal or an external? Why is knowing what modality you typically...
• describe the basic functions of each component (block) of the ext4 filesystem.