Java Reference
In-Depth Information
program should output the roots of the quadratic equation. (Hint: Use the
method pow or sqrt from the class Math to calculate the square root.
Chapter 3 explains how to use these methods.)
9. Write a program that mimics a calculator. The program should take as input
two integers and an arithmetic operation ( + , - , * ,or / ) to be performed. It
should then output the numbers, the operator, and the result. (For division,
if the denominator is zero, output an appropriate message.) Some sample
outputs follow:
3 + 4 = 7
13 * 5 = 65
10. Redo Exercise 9 to handle floating-point numbers. (Format your output to
two decimal places.)
11. Redo Programming Exercise 16 of Chapter 2, taking into account that your
parents buy additional savings bonds for you as follows:
a. If you do not spend any money to buy savings bonds, then because you
had a summer job, your parents buy savings bonds for you in an
amount equal to 1% of the money you save after paying taxes and
buying clothes, school supplies, and other accessories.
b. If you spend up to 25% of your net income to buy savings bonds, your
parents spend $0.25 for each dollar you spend to buy savings bonds,
plus money equal to 1% of the money you save after paying taxes and
buying clothes, school supplies, and other accessories.
c. If you spend more than 25% of your net income to buy savings bonds,
your parents spend $0.40 for each dollar you spend to buy savings
bonds, plus money equal to 2% of the money you save after paying
taxes and buying clothes, school supplies, and other accessories.
12. A bank in your town updates its customers' accounts at the end of each month.
The bank offers two types of accounts: savings and checking. Every customer
must maintain a minimum balance. If a customer's balance falls below the
minimum balance, there is a service charge of $10.00 for savings accounts and
$25.00 for checking accounts. If the balance at the end of the month is at least
the minimum balance, the account receives interest as follows:
a. Savings accounts receive 4% interest.
b. Checking accounts with balances of up to $5000 more than the mini-
mum balance receive 3% interest; otherwise, the interest is 5%.
Write a program that reads a customer's account number ( int type),
account type ( char type; s or S for savings, c or C for checking), minimum
balance that the account should maintain, and current balance. The
program should then output the account number, account type, current
Search WWH ::




Custom Search