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...
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...
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...
PART B- Javascript Using a text editor (VS Code or Notepad) and a web browser, you...
PART B- Javascript Using a text editor (VS Code or Notepad) and a web browser, you will demonstrate how to create an HTML file, externally link a JavaScript file, and write some source code in the JavaScript file. a..Create two blank files to be an HTML file and a JavaScript file. The file names should be partA.html and partA.js. b.. Create a basic HTML webpage structure. c..Link the JavaScript file to the HTML file using the <script> tag. d.. Prompt...
For this program you will be looking at future tuition at your university. In 2020, the...
For this program you will be looking at future tuition at your university. In 2020, the tuition for a full time student is $6,540 per semester, the tuition for a part time student is $3,320. The tuition will be going up for the next 7 years at a rate of 3.5% per year. Write a program using if-else and a loop. Ask the user if they are a full time or part time student, then display the projected semester tuition...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName (a String), numSold (an integer that represents the number of that type of game sold), and priceEach (a double that is the price of each of that type of Game). I only want three instance variables!! The class should have the following methods: A constructor that has two parameter – a String containing the name of the Game and a double containing its price....
Write a program that takes two numbers from the Java console representing, respectively, an investment and...
Write a program that takes two numbers from the Java console representing, respectively, an investment and an interest rate (you will expect the user to enter a number such as .065 for the interest rate, representing a 6.5% interest rate). Your program should calculate and output (in $ notation) the future value of the investment in 5, 10, and 20 years using the following formula: future value = investment * (1 + interest rate)year We will assume that the interest...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT