Question

In java how do you write an inflation calculator. Input should be amount, rate of inflation...

In java how do you write an inflation calculator. Input should be amount, rate of inflation and number of years. Output should be the future value of the amount.

Example Output:

Enter the current cost of the item: 1000

Enter the expected inflation rate per year

(Enter as a percentage and do not include the percent sign): 6

Enter the whole number of years in the future to project cost: 10

At 6.00% inflation per year, the cost in 10 year(s) will be $1,790.85.

Process completed

Homework Answers

Answer #1

import java.util.Scanner;

public class Inflation {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter the current cost of the item: ");
        double value = in.nextDouble();
        System.out.println("Enter the expected inflation rate per year");
        System.out.print("(Enter as a percentage and do not include the percent sign): ");
        double rate = in.nextDouble();
        System.out.print("Enter the whole number of years in the future to project cost: ");
        int numYears = in.nextInt();
        double finalValue = Math.pow(1 + rate / 100, numYears) * value;
        System.out.printf("At %.2f%% inflation per year, the cost in %d year(s) will be $%,.2f.\n", rate, numYears, finalValue);
        System.out.println("Process completed");
    }
}



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
Write an inflation calculator. Input should be amount, rate of inflation and number of years. Output...
Write an inflation calculator. Input should be amount, rate of inflation and number of years. Output should be the future value of the amount. -Java need help please
Problem a (PA5a.java) Write a program that deals with inflation, which is essentially the rising cost...
Problem a (PA5a.java) Write a program that deals with inflation, which is essentially the rising cost of general goods over time. That is, the price of goods, such as a packet of peanuts, goes up as time goes by. So, you will write a program to gauge the expected cost of an item in a specified number of years. The program asks for the cost of the item, the number of years, and the rate of inflation. The output is...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will produce the following report (as shown). The first item in the report is a number with starting value 1. Second column is the word “ X ” (representing the times symbol). Third column is the table-number (itself). Following is an equal sign “ = “ (representing a result). Last column is the result of the operation for that line or row which is the...
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...
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...
1.) Do you think the inflation rate will decrease, increase, or stay the same over the...
1.) Do you think the inflation rate will decrease, increase, or stay the same over the next couple of years? Explain your reasoning. 2.) WHich of the following economic changes are consistent with cost-push inflation? Check all that apply * rising economic output * an increase in the price level * falling economic output
Do not round intermediate calculations. Final dollar answers should be rounded to two decimal places. Final...
Do not round intermediate calculations. Final dollar answers should be rounded to two decimal places. Final interest rate answers should be rounded to 4 decimal places if stated as a percentage, and 6 decimal places otherwise. Final answers indicating periods should be rounded up to whole periods. PLEASE SHOW ALL WORK! WITHOUT FINANCIAL CALCULATOR Vita-Chips Co. has invested in a new plant that will produce nutritious corn chips. The initial cost is $120 million. The company anticipates net cash flows...
In this project, you will write a Java program that randomly generates annual salaries for professors...
In this project, you will write a Java program that randomly generates annual salaries for professors in the Computer Science and Engineering Technology (CSET) program at the University of Toledo in the past 10 years. Assume that there are five CSET professors. You should have a twodimensional array of values representing salaries. The first dimension represents the professors and the second dimension represents the years of the salaries. You should have a constructor that takes two integers representing the number...
PLEASE SHOW STEP BY STEP AND HOW TO SOLVE USING FINANCIAL CALCULATOR FUNCTIONS: You are a...
PLEASE SHOW STEP BY STEP AND HOW TO SOLVE USING FINANCIAL CALCULATOR FUNCTIONS: You are a marketing executive at a Boston based Marketing corporation. A client has come to you and said they would like to take on a marketing project if it will EFFECTIVELY earn them 10.00% per year. The project you proposed will cost $100,000 today and $20,000 next year (one year from today). The project will bring in equal cash flows starting next quarter, with the last...
Write a Java program named BinaryConversion that will convert base 2 numbers to base 10 numbers....
Write a Java program named BinaryConversion that will convert base 2 numbers to base 10 numbers. The data for this program will be entered from the keyboard using JOptionPane one 16-bit binary number at a time. Note that each base 2 number is actually read in as a String. The program should continue until a 16-bit base 2 number consisting of all 0’s is entered. Once the 16-bit number has been entered your program should make sure that the input...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT