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);

Homework Answers

Answer #1

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

___________________________________________________________________


Note: If you have queries or confusion regarding this question, please leave a comment. I would be happy to help you. If you find it to be useful, please upvote.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
5) Create a Java program using Scanner: Write a program where you will enter the grade...
5) Create a Java program using Scanner: Write a program where you will enter the grade score for 5 classes, then it will display total points and average and it will display the grade based on percentage. Steps: 1) Declare variable integer for English, Chemistry, Java Programming, Physics and Math 2) Declare variable total and percentage 3) Create Scanner object and prompt the user to enter grades for each class and input grades after each class 4) Calculate total of...
4) Create the following in a Java program. Create a Scanner Prompt the user to Receive...
4) Create the following in a Java program. Create a Scanner Prompt the user to Receive the amount and declare the variable double amount for scanner Declare variable integer remaining amount which is equal to (int) (amount*100) Find the number of one dollars bt declaring the integer variable which is equal to remaining amount divided by 100 Declare: remaining amount %=100 Find the number of quarters: Declare integer variable number of quarters equal to remaining amount divided by 25 Declare:...
4) Write a Java program using Conditions: Write a program where it will ask user to...
4) Write a Java program using Conditions: Write a program where it will ask user to enter a number and after that it will give you answer how many digits that number has. Steps: 1) Create Scanner object and prompt user to enter the number and declare variable integer for input 2) Use if else condition with && condition where you will specify the digits of numbers by writing yourself the digit number that should display: Example(num<100 && num>=1), and...
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1....
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January - December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs to adjust the...
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1....
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January" through "December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs to adjust the...
rite a Java Program to play your version of the Texas Pick 3 Lottery. You will...
rite a Java Program to play your version of the Texas Pick 3 Lottery. You will need to include the provided code given below in your program. Task:The program will prompt for a number between 0 and 999. Your program will display the number of attempts it took for the entered number to match a randomly generated number. In the main() method, declare an int named myPick3choice. Create a prompt for myPick3choice as "Enter your Pick 3 choice:0-999". Create a...
Java Programming COMP-228 LAB ASSIGNMENT #1 >> Apply the naming conventions for variables, methods, classes, and...
Java Programming COMP-228 LAB ASSIGNMENT #1 >> Apply the naming conventions for variables, methods, classes, and packages: - variable names start with a lowercase character for the first word and uppercase for every other word - classes start with an uppercase character of every word - packages use only lowercase characters - methods start with a lowercase character for the first word and uppercase for every other word Java Programming COMP-228 Exercise #1: [5 marks] Write a Java application using...
In JAVA the question will change as the quiz goes on (You don't have to do...
In JAVA the question will change as the quiz goes on (You don't have to do the whole project I just need help with the bolded portion of the question) Design an interactive multiple-choice quiz app on your choice of subject. Your quiz must consist of at least 10 questions. You must have to use nested layouts and customize the buttons used in your app. The app must also display the user’s progress throughout the quiz, showing the question number...
NEED: VBA Subroutine Pls, do not use Class Exmp: Sub FutureAccountValue() Dim Deposit As Single Dim...
NEED: VBA Subroutine Pls, do not use Class Exmp: Sub FutureAccountValue() Dim Deposit As Single Dim AddContribution As Single Dim Years As Single Dim InterestRate As Single ..... // Sub 1) Write a subroutine that asks the user for: The deposit Amount The additional contribution (deposit) each year The number of Years The interest Rate (APR) Then, display the future value of the user’s account each year for some number of years. Also show the growth from the original investment...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT