You are on page 1of 1

Activity 4.

1
Answer as indicated. Please attach a java file to validate your answer.

1. Write a program that displaysthe recommended weight, given the user’s age and height.
The formula for calculating the recommeded weight is
recommendedWeight = (height - 100 + age / 10) * 0.90
Define a service class named Height and include an appropriate method for gettin a
recommended weight of a designated height.

2. Write a program that accepts the unit weight of a bag of coffee in pounds(Lb) and the
number of bags sold and displays the total price of the sale, computed as follows;
totalPrice = bagWeight * numberOfBags * pricePerLb;
totalPriceWithTax = totalPrice + totalPrice * taxrate;

Display the result in the following manner:

Numbber of bags sold : 32


Weight per bag : 5 lb
Price per pound : $5.99
Sales Tax : 7.25%

Total Price : $1027.88

Define and use programmer-defined CoffeBag class. Include class constants for the
price per round and tax rate with the values $5.99 per round and 7.25 percent, respectively.

You might also like