Question

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

Homework Answers

Answer #1
//InflationCalculator.java
import java.util.Scanner;
public class InflationCalculator {
    public static void main(String[] args) {
        double amount, rate;
        int years;
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter amount: ");
        amount = scanner.nextDouble();
        System.out.print("Enter inflation rate: ");
        rate = scanner.nextInt();
        System.out.print("Enter number of years: ");
        years = scanner.nextInt();

        for(int i = 0;i<years;i++){
            amount = amount + (amount*rate/100.0);
        }

        System.out.println("Final amount = "+amount);
    }
}

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
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...
Write a program that mimics a calculator. The program should take as input two integer and...
Write a program that mimics a calculator. The program should take as input two integer and an arithmetic operation (+, -, *, /, %) to be performed. It should then output the numbers the operator and the result. Division by zero??
Write a program that input some number of cents (see less than 100), and output the...
Write a program that input some number of cents (see less than 100), and output the number of quarters, dimes, nickels and pennies needed to add up to that amount (thinking how a cashier needs to return you back some small changes).
Write a Java method that takes a String as Input and replaces the first two occurrencesof...
Write a Java method that takes a String as Input and replaces the first two occurrencesof a given character to another provided character.   For example, if the input String is “Java is Great” and asked to replace the letter a with x then the output would be: “Jxvx is Great” The method takes a String and two characters and returns the modified String. Please make your own assumptions if needed, you do not need to write the main.
Write a function find square root(x) that takes as input a number x and as output...
Write a function find square root(x) that takes as input a number x and as output returns the square root of x. Your results should converge to at least 6 decimal places. matlab question
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...
Given this input, write the python code that returns the specified output Input X= ["This is...
Given this input, write the python code that returns the specified output Input X= ["This is a wolf #scary",     "welcome to the jungle #missing",     "11132 the number to know",     "Remember the name s - John",     "I      love      you"] Output This is wolf scary welcome to the jungle missing the number to know Remember the name John I love you
IN C++ PLEASE. Write a program where the user enters a number and you output an...
IN C++ PLEASE. Write a program where the user enters a number and you output an unfilled square of stars. (DO NOT PROMPT THE USER, just take in a number, The only console output should be the squares). For example the program would start with console input, The user would enters 3, you would output (note 3 is the lowest number your program will be tested with) *** * * *** or, The user enters 5, you would output *****...
Question: Write any java program. Your Program must include loops, decision structures, input and output, comments.
Question: Write any java program. Your Program must include loops, decision structures, input and output, comments.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT