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...
Create a Java Program to calculate compound interest. This can all be done in the main()...
Create a Java Program to calculate compound interest. This can all be done 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 currentBalance to newBalance....
Write a Java program in Eclipse to calculate the total cost to enter into a waterpark...
Write a Java program in Eclipse to calculate the total cost to enter into a waterpark for a family/group Ticket rates are listed below kids (Age 12 and under)=$ 12.50 Regular( Age between12 -55) =$ 18.25 Seniors (55 and above) = $15.00 Tax =7% Your program should ask the user to enter the total number of members in their group. User needs to enter the ages for all members. Write appropriate error messages for invalid entries. An array should be...
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...
Create a java program that allows people to buy tickets to a concert. Using java create...
Create a java program that allows people to buy tickets to a concert. Using java create a program that asks for the users name, and if they want an adult or teen ticket. As long as the user wants to purchase a ticket the program with "yes" the program will continue. When the user inputs "no" the program will output the customer name, total amount of tickets, and the total price. The adult ticket is $60 and the child ticket...
Java Using NetBean Calculate the interest for a bank account. Your program should use Scanner to...
Java Using NetBean Calculate the interest for a bank account. Your program should use Scanner to collect account balance and interest rate (input 2.5 for 2.5%), and then output the interest should be paid. interest = balance * interest_rate;
(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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT