Question

In: Computer Science

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
  • Increase interest rate to 10%
  • Print interest amount and total balance
  • Increase initial balance to 2000
  • Print interest amount and total balance

Solutions

Expert Solution

//Java program

class Account{
   private double Balance;
   private double interest_rate;
  
   public Account(double bal,double interest) {
       Balance = bal;
       interest_rate = interest;
   }
  
   public void setBalance(double balance) {
       Balance = balance;
   }
   public double getBalance() {
       return Balance;
   }
   public void setInterestRate(double interest) {
       interest_rate = interest;
   }
   public double getInterestRate() {
       return interest_rate;
   }
}

public class Main {
   public static void main(String args[]) {
       Account acc = new Account(1000,5);
       double interest = acc.getBalance()*acc.getInterestRate()/100;
       System.out.println("Interest : "+interest);
      
       System.out.println("Total Balanace : "+(interest+acc.getBalance()));
      
       acc.setInterestRate(10);
       interest = acc.getBalance()*acc.getInterestRate()/100;
       System.out.println("Interest : "+interest);
       System.out.println("Total Balanace : "+(interest+acc.getBalance()));
      
       acc.setBalance(2000);
       interest = acc.getBalance()*acc.getInterestRate()/100;
       System.out.println("Interest : "+interest);
       System.out.println("Total Balanace : "+(interest+acc.getBalance()));
   }
}
//sample output


Related Solutions

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 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...
In java Write a program called FileProcessor.java that reads the file numbers.txt, and: Calculate the total...
In java Write a program called FileProcessor.java that reads the file numbers.txt, and: Calculate the total number of numbers in the file, Calculate the sum of all the numbers in the file, Calculate the average of all the numbers in the file, Find the smallest value of all the numbers in the file, Find the largest value of all the numbers in the file, Calculate the standard deviation of all the numbers in the file
Create a Java Program to calculate luggage costs. USING ECLIPSE IDE The Business Rules are: A....
Create a Java Program to calculate luggage costs. USING ECLIPSE IDE The Business Rules are: A. Two bags per person are free. B. The Excess Bag Charge is $75 per bag. The program needs to do the following: 1. In your main method(),    Create integers to store the number of Passengers and also the total number of bags    Prompt for the number of passengers on a ticket.    Prompt for the total number of bags for all passengers...
Create a Java Program to show a savings account balance. using eclipse IDE This can be...
Create a Java Program to show a savings account balance. using eclipse IDE This can be done in the main() method. Create an int variable named currentBalance and assign it the value of 0. Create an int variable named amountToSaveEachMonth. Prompt "Enter amount to save each month:" and assign the result to the int variable in step 2. Create an int variable name numberOfMonthsToSave. Prompt "Enter the number of months to save:" and store the input value into the variable...
In java. Prefer Bluej Create a program in java that calculates area and perimeter of a...
In java. Prefer Bluej Create a program in java that calculates area and perimeter of a square - use a class and test program to calculate the area and perimeter; assume length of square is 7 ft.
in java we need to order a list , if we create a program in java...
in java we need to order a list , if we create a program in java what  are the possible ways of telling your program how to move the numbers in the list to make it sorted, where each way provides the required result. list the name of sorting with short explanation
Needs to be in JAVA. Write a Java program that accepts the total amount of cars...
Needs to be in JAVA. Write a Java program that accepts the total amount of cars sold and total sales amount of a car salesperson for a given month. The salesperson’s paycheck is computed as follows: a. Every sales person gets 10% (commission) of total sales b. Sales totals greater than $50,000 get 5% of total sales amount c. 8 or more cars sold earns the salesperson an extra 3% Please remove 30% (taxes) of the gross pay and list...
(java ) Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate...
(java ) Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has ondeposit. Provide method calculateMonthlyInterest to calculate the monthly www.oumstudents.tk interest by multiplying the savingsBalance by annualInterestRate divided by 12 this interest should be added to savingsBalance. Provide a static method modifyInterestRate that sets the annualInterestRate to a new value. Write a program...
Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT