Question

In: Computer Science

Calculate Interest in a Java program. If you know the balance and the annual percentage interest...

Calculate Interest in a Java program.

If you know the balance and the annual percentage interest rate, you can compute the interest on the next monthly payment
using the following formula: interest = balance * (annualInterestRate/1200)

Write a program that reads the balance and the annual percentage interest rate and
displays the interest for the next month.

Create a scanner
Prompt the user to enter a name and create variable for scanner
Prompt the user to enter a balance and the annual percentage interest rate
Create variable double balance for scanner
Create variable double annual for interest rate for scanner

Create variable double interest which is equal to annual for interest rate divided by 1200

Display result of balance

Solutions

Expert Solution

Here is the solution to above problem in Java. Please read the code comments for more information

JAVA CODE

import java.util.*;
public class Main
{
   public static void main(String[] args) {
   //create the Scanner variable
   Scanner sc = new Scanner(System.in);
   //Create variable to take input and result
   double balance,annual,interest;
   //prompt user for balance
       System.out.print("Enter Balance: ");
       balance = sc.nextDouble();
       //prompt user for annual interest rate
       System.out.print("Annual Percentage Interest Rate: ");
       annual = sc.nextDouble();
       //calculate the Interest
       interest = balance *(annual/1200);
       System.out.println("Interest is: " + interest);
      
   }
}


Related Solutions

In java Create a program to calculate interest rate and total balance - the program consists...
In java Create a program to calculate interest rate and total balance - the program consists of (a) A class that encapsulates the interest rate and total balance calculation Constructor should accept initial balance and interest rate Methods: Returns interest rate Returns total balance Set interest rate Set initial balance (b) A test program that uses class from step (A) to perform the following: Set interest rate to 5% and initial balance to 1000 Print interest amount and total balance...
Problem 1: In java Create a program to calculate interest rate and total balance - the...
Problem 1: In java Create a program to calculate interest rate and total balance - the program consists of (a) A class that encapsulates the interest rate and total balance calculation Constructor should accept initial balance and interest rate Methods: Returns interest rate Returns total balance Set interest rate Set initial balance (b) A test program that uses class from step (A) to perform the following: Set interest rate to 5% and initial balance to 1000 Print interest amount and...
Calculate the Annual Percentage Yield (APY) on an account that has a stated interest rate of...
Calculate the Annual Percentage Yield (APY) on an account that has a stated interest rate of 6.21% . Presume your account you deposit 5,875 a year for the next 42 years. Calculate the value of your portfolio when the interest is compounded yearly, quarterly, monthly, and daily.
Java Write a program to record the GPAs of a class and find the percentage of...
Java Write a program to record the GPAs of a class and find the percentage of students in each GPA. The program first allows the user to enter the number of students enrolled in the class, and then to enter the GPA of all students one by one. For each student, the input must be between 1 and 4 inclusively. Otherwise, the software displays a message as “Invalid number!” and asks for a new GPA for the same student Enter...
Determine the actual annual interest rate on a $100,000 line of credit with an annual percentage...
Determine the actual annual interest rate on a $100,000 line of credit with an annual percentage rate of 10% compounded monthly. The bank requires that a 5% compensating balance be placed in an interest-bearing account that pays an annual percentage rate of 1.5% compounded monthly. The average daily balance is anticipated to be $75,000, excluding the compensating balance and interest due on the line of credit.
To model repayment of a loan, you need to calculate the interest on the balance and...
To model repayment of a loan, you need to calculate the interest on the balance and deduct any payments made. So if the balance at the start of the period is L the balance at the end of the period before the payment is L(1+r) where r is the interest rate per period (e.g. if the payments are monthly, it is a monthly interest rate) and the balance after the payment is L(1+r)−P where P is the payment per period...
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements,...
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements, write a loop, use arrays, obtain input from the user, display output, test and create a JavaDoc. Create project PaystubTest2 that is a Paystub calculator with program Paystub##.java (where ## is your initials) based on user input. (10 points) You must use the ReadStringFromUser and ReadFloatFromUser methods in the program to obtain user input. (20 points) This program will calculate the Gross Earnings, FICA...
Writing a Java Code Requirements of the JAVA program: Your task is to calculate geometric area...
Writing a Java Code Requirements of the JAVA program: Your task is to calculate geometric area for 3 shapes(square, rectangle and circle). You need to build a menu that allows users to enter options. Possible options are 'S' for square, 'R' for rectangle and 'C' for circle. HINT: you can use switch statement to switch on string input Invalid input should throw a message for the user. Example: Invalid input, please try again Each options should ask users for relevant...
Welcome to the Bruins Goalie Saves Analysis This program will calculate the percentage of saves for...
Welcome to the Bruins Goalie Saves Analysis This program will calculate the percentage of saves for a hockey goalie for 4 games after you have entered the games and saves for the goalie. Enter the number of goals for game #1: 3 Enter the number of saves for game #1: 22 The percent saves for game #1 is 88.0% Enter the number of goals for game #2: 4 Enter the number of saves for game #2: 33 The percent saves...
TRUE OR FALSE Interest is stated in terms of an annual percentage rate to be applied...
TRUE OR FALSE Interest is stated in terms of an annual percentage rate to be applied to the face value of the loan. The employer is required to match the amount of FICA taxes withheld for each employee, effectively doubling the amount paid into Social Security. A contingent liability is recorded only if a loss is at least reasonably possible and the amount is reasonably estimable. A lower current ratio or acid-test ratio generally indicates a greater ability to pay...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT