CS141-Assignment 1 Solved

25.00 $

Category:

Description

5/5 - (1 vote)

Variables, Constants, Calculations

Please start with the file named Vars_Consts_Calculations.java and follow the directions there. The file can be found next to this assignment’s PDF.

Restaurant Bill

Write a program that computes tax and tip on a restaurant bill. Ask user to input the bill amount and the tip percentage he/she wants to give to the waiter. The tax should be 10% of the meal cost, and must be set as a constant in your code. The tip should be calculated after adding tax. Display the meal cost, tax amount, tip amount, and total bill on the screen.

Name your project RestaurantBill.java.

Interest Earned

Assuming there are no deposits other than the original investment, the balance in a savings account after one year might be calculated as:

 

Amount = Principal * (1 + Rate/T)T  

 

Principal is the balance in the savings account, Rate is the interest rate (in decimal form – 0.0425 for 4.25%), and T is the number of times the interest is compounded during a year (T is 4 if the interest is compounded quarterly).

Write a program that asks for the principal, the interest rate, and the number of times the interest is compounded. See a sample output below.

 

Interest rate:              4.25%

 

Times compounded:           12

Principal:                 $1000.00

Interest:                  $43.34

Amount in Savings:         $1043.34

 

Name your project InterestEarned.java.

   

Vending Machine

Write a program that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and 1 dollar, in 5-cent increments (25, 30, 35,…, 90, 95, 100), and the machine accepts only a single dollar bill to pay for the item. For example, a possible sample dialog might be the following:

Enter price of item

(from 25 cents to a dollar, in 5-cent increments):

45

 

You bought an item for 45 cents and gave me a dollar,

So your change is 2 quarters

0 dimes, and 1 nickels.

 

  • Assignment01-bo5nh4.zip