//interface
interface Interest
{
public double compoundInterest();
public double simpleInterest();
}
//saving account class
class SavingAccount implements Interest
{
//data member declaration
double A;
double R;
double T;
//default constructor
SavingAccount()
{
A = 0;
R = 0;
T = 0;
}
//parameterize constructor
SavingAccount(double amount, double rate, double time)
{
A = amount;
R = rate;
T = time;
}
//method to calculate compund interest
public double compoundInterest()
{
double compInterest;
compInterest = A * Math.pow(1 + R / 100, T);
compInterest = compInterest - A;
return compInterest;
}
//method to calculate simple interest
public double simpleInterest()
{
double simpInterest;
simpInterest = A * R * T / 100;
return simpInterest;
}
};
public class Main
{
public static void main(String[] args)
{
//create object
SavingAccount sa = new SavingAccount(100, 5, 2);
//method calling
double compInterest = sa.compoundInterest();
double simpInterest = sa.simpleInterest();
//display the result
System.out.println("Compound
interest is = " + compInterest);
System.out.println("Simple interest
is = " + simpInterest);
}
}
OUTPUT:
Using Java language 3. Create an interface Interest. It should have two methods, compound interest and...
Write a Java interface called Salience that includes two methods: setSalience and getSalience. The interface should define a way to establish numeric salience among a set of objects. Design and implement a class called Task that represents a task (such as on a to-do list) that implements the Salience interface. Create a driver class to exercise some Task objects.
Please write a Java interface for an integer stack (should have the methods push, pop, toString). Then implement this interface using one of our linked list nodes. Then please write an interface for an integer queue ( should have methods enqueue, dequeue, and toString). Then implement this interface using one of our linked list objects. Please see chapter 3 in the text for a definition of a stack. Please write a program that asks the user for how many numbers...
Create a Java file called CompoundInterestYourLastName. Write a method called computeBalance( ) that computes the balance of a bank account with a given initial deposit, annual interest rate, after a given number of years for the investment. Assume interest is compounded yearly. The formula for determining compound interest (compounded yearly) is: A space equals space P space left parenthesis space 1 plus r space right parenthesis space to the power of t space where: A = the future value of...
In Java
Create an interface called
Amount
that includes a method called
setPrice
().
Create an abstract class named
Book
that inherits from the interface Amount. Include a String field
for
the book’s
title
and a double field for the book’s
Price
. Within the class, include a constructor that
requires the book title and add
two getter methods
— one that returns the title and one that returns the
price. Include an abstract method named
setPrice
().
Create a...
14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount that was deposited into the account, but also on the interest that has accumulated over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account afer a specified namber of years is The terms in the formula are A is...
Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account. --->Console Welcome to the Account application Starting Balances Checking: $1,000.00 Savings: $1,000.00 Enter the transactions for the month Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500 Continue? (y/n): y Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200 Continue? (y/n): n Monthly Payments and Fees Checking fee: $1.00 Savings...
2. Continuous compound interest can be calculated using the formula A(t) = Perl, where P is the initial amount and At) is the value after time t at interest rater (as a decimal). (a) When Angela was born, her grandparents deposited $5,000 into a college savings account paying 6% interest compounded continuously. What is the balance after 15 years? Round your answer to two decimal places. (b) If her grandparents want her to have $15,000 after 17 years, how much...
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?
********************Java Assigment******************************* 1. The following interface and classes have to do with the storage of information that may appear on a mailing label. Design and implement each of the described classes below. public interface AddrLabelInterface { String getAttnName(); String getTitle(); // Mr., Mrs., etc. String getName(); String getNameSuffix(); // e.g., Jr., III String getProfessionalSuffix(); // O.D. (doctor of optometry) String getStreet(); String getSuiteNum(); String getCity(); String getState(); String getZipCode(); } Step 1 Create an abstract AddrLabel class that implements the...
Numerical Methods (matlab code)
QUESTION 2 A friend wants to deposit $2000 into a savings account. She goes to two banks and is offered competing interest rates for the account. Bank 1 has a 10% interest rate, and compounds once annually. Bank 2 has an 9% interest rate, but compounds monthly. Use the following annually compounded interest formula, A= P(1+r) where A is the accumulated amount, P is the principal amount deposited, r is the annual interest rate (as a...