Question

Create a Java program named Saving.java that prompts for two double values: savings balance and interest...

Create a Java program named Saving.java that prompts for two double values: savings balance and interest rate. Calculate the savings balance at the end of the year. Hint, use %,10.2f with a printf statement for format your result:

% java Savings

Enter your current savings balance: 100000

Enter annual interest rate: 5.1

In one year you will have $105,100.00

anyone can help creat a java program?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello,

Here is the code, also I have enclosed the screenshot of the result for your reference.

Thank you,

import java.util.Locale;
import java.util.Scanner;

public class Saving{

    public static void main(String [] args){

        double savings, interest, finalValue;
        Scanner sc1 = new Scanner(System.in);
        System.out.print("Enter your current savings balance:"); // Get the savings from user
        System.out.println(" ");
        savings = sc1.nextDouble();

        Scanner sc2 = new Scanner(System.in);
        System.out.print("Enter annual interest rate:"); // Get the interest rate from user
        System.out.println(" ");
        interest = sc2.nextDouble();
        
        finalValue = (interest/100)*savings + savings; // Calculate interest 
        System.out.print("In one year you will have $");
        System.out.printf(Locale.US, "%,10.2f %n", finalValue); // Display the o/p in desired format

    }
}

Add a comment
Answer #2

Sure, I can help you create the Java program. Here's the code for the Saving.java program:

javaCopy codeimport java.util.Scanner;public class Saving {    public static void main(String[] args) {        // Create a Scanner object to read user input
        Scanner scanner = new Scanner(System.in);        // Prompt the user for current savings balance
        System.out.print("Enter your current savings balance: ");        double savingsBalance = scanner.nextDouble();        // Prompt the user for annual interest rate
        System.out.print("Enter annual interest rate: ");        double interestRate = scanner.nextDouble();        // Calculate the savings balance at the end of the year
        double endBalance = savingsBalance * (1 + interestRate / 100);        // Display the result with two decimal places
        System.out.printf("In one year you will have $%,10.2f%n", endBalance);        // Close the Scanner
        scanner.close();
    }
}

To run the program, follow these steps:

  1. Open a text editor and paste the code above into a new file.

  2. Save the file with the name Saving.java.

  3. Open a command prompt or terminal and navigate to the directory where you saved the Saving.java file.

  4. Compile the program by running the command: javac Saving.java

  5. Run the program by running the command: java Saving

Now, you can enter the current savings balance and annual interest rate when prompted, and the program will calculate and display the savings balance at the end of the year as shown in your example.

answered by: Hydra Master
Add a comment
Answer #3

Below is the Java program named Saving.java that prompts for the savings balance and interest rate, calculates the savings balance at the end of the year, and then prints the result using the desired format:

javaCopy codeimport java.util.Scanner;public class Savings {    public static void main(String[] args) {        Scanner scanner = new Scanner(System.in);        // Prompt for savings balance
        System.out.print("Enter your current savings balance: ");        double savingsBalance = scanner.nextDouble();        // Prompt for annual interest rate
        System.out.print("Enter annual interest rate: ");        double interestRate = scanner.nextDouble();        // Calculate the savings balance at the end of the year
        double balanceAtEndOfYear = savingsBalance * (1 + interestRate / 100);        // Print the result with the desired format
        System.out.printf("In one year you will have $%,10.2f\n", balanceAtEndOfYear);

        scanner.close();
    }
}

You can compile and run this program using any Java IDE or from the command line:

  1. Save the above code in a file named Savings.java.

  2. Open a terminal or command prompt and navigate to the directory where you saved Savings.java.

  3. Compile the program by running: javac Savings.java

  4. Run the program by running: java Savings

Now you can enter the savings balance and interest rate, and the program will calculate and display the savings balance at the end of the year in the desired format.


answered by: Mayre Yıldırım
Add a comment
Know the answer?
Add Answer to:
Create a Java program named Saving.java that prompts for two double values: savings balance and interest...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a Java Program/Class named ComputeInterest to calculate compound interest. This can all be done entirely...

    Create a Java Program/Class named ComputeInterest to calculate compound interest. This can all be done entirely in the main() method. Create a double variable named currentBalance. Create a double variable named newBalance. Create a final double variable named INTEREST_RATE and assign 1.05 to it. Create a int variable named yearCount. Prompt for the "Number of years to invest" and store the input into the yearCount variable. Prompt for the "Amount to Invest" and store this in the currentBalance variable. Assign...

  • IN JAVA 1. Create a program that prompts the user for an integer and then displays...

    IN JAVA 1. Create a program that prompts the user for an integer and then displays a message indicating whether or not the number is a perfect square. This can be determined by finding the square root of a number, truncating it (by casting the double result), and then squaring that result 2. Write a program that prompts the user for two numbers. The first number is a minimum value and the second number is a maximum value. RandomNum then...

  • Create a payroll program named CalcPay that allows the user to enter two double valuesand a...

    Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output. The...

  • Create a payroll program named CalcPay that allows the user to enter two double valuesand a...

    Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output. The...

  • Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate....

    Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate. ·         The application calculates the interest amount and formats the loan amount, interest rate, and interest amount. Then, it displays the formatted results to the user. ·         The application prompts the user to continue. ·         The program stops prompting the user for values after taking 3 loan amounts. ·         The application calculates and displays the total loan and interest amount and ends the program Example Output Welcome to...

  • JAVA PLEASE! Suppose you save $100 each month into a savings account with the annual interest...

    JAVA PLEASE! Suppose you save $100 each month into a savings account with the annual interest rate 5%. So, the monthly interest rate is 0.05/12 = 0.00417. After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 After the second month, the value in the account becomes (100 + 100.417) * (1 + 0.00417) = 201.252 After the third month, the value in the account becomes (100 + 201.252) * (1 + 0.00417)...

  • Create an applet payroll program named CalcPay that allows the user to enter two double valuesand...

    Create an applet payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay by pressing CALCULATE button. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up...

  • java programe Write a program that prompts the user to enter in an integer number representing...

    java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...

  • Write a program named "VegetablePricer" which prompts the user for a vegetable from the pricing table...

    Write a program named "VegetablePricer" which prompts the user for a vegetable from the pricing table shown below. The program will then display the cost per pound for that vegetable, again using the table provided. Your program must use a switch statement to process the input value and display the desired output. Be sure to provide a default case in your switch statement which handles unrecognized input. Use named constants for all constant strings (e.g. prompts and vegetable names) and...

  • PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field...

    PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field named id for the savings account. A private float data field named balance for the savings account. A private float data field named annuallnterestRate that stores the current interest rate. A_init_ that creates an account with the specified id (default 0), initial balance (default 100), and annual interest rate (default 0). . The accessor and mutator methods for id, balance, and annuallnterestRate. A method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT