created 08/02/99
During a special sale at a store, a 10% discount is taken on purchases over $10.00. Write a program that asks for the amount of purchases, then calculates the discounted price. The purchase amount will be input in cents (as an integer):
Enter amount of purchases: 2000 Discounted price: 1800
Use integer arithmetic throughout the program.
Click here to go back to the main menu.Bob's Discount Bolts charges the following prices:
Write a program that asks the user for the number of bolts, nuts, and washers in their purchase and then calculates and prints out the total. As an added feature, the program checks the order. It is usually a mistake if there are more bolts than nuts. In this case the program writes out "Check the Order." Otherwise the program writes out "Order is OK." In either case the total price is written out.
Number of bolts: 12 Number of nuts: 8 Number of washers: 24 Check the Order Total cost: 108Use constants for the unit cost of each item. In other words, declare something like
final int boltPrice = 5;
Al's Last Chance Gas station sits on Route 190 on the edge of Death Valley. There is no other gas station for 200 miles. You are to write a program to help drivers decide if they need gas. The program asks for:
The program then writes out "Get Gas" or "Safe to Proceed" depending on if the car can cross the 200 miles with the gas remaining in the tank.
Tank capacity: 12 Gage reading: 50 Miles per gallon: 30 Get Gas!
Click here to go back to the main menu.
At the State Fair Pie Eating Contest all contestants in the heavyweight division must weigh within 30 pounds of 250 pounds. Write a program that asks for a contestant's weight and then says if the contestant is allowed in the contest.
Click here to go back to the main menu.Different packages of ground beef have different percentages of fat and different costs per pound. Write a program that asks the user for:
The program then calculates the cost per pound of lean (non-fat) beef for each package and writes out which is the best value.
Price per pound package A: 2.89 Percent lean package A: 85 Price per pound package B: 3.49 Percent lean package B: 93 Package A cost per pound of lean:3.4 Package B cost per pound of lean:3.752688 Package A is the best value
Assume that the two packages will not come out equal in value.
Click here to go back to the main menu.Write a program that asks a user for their birth year encoded as two digits (like "62") and for the current year, also encoded as two digits (like "99"). The program is to correctly write out the users age in years.
Year of Birth: 62 Current year: 99 Your age: 37 ----- another run of the program -------- Year of Birth: 62 Current year: 00 Your age: 38Click here to go back to the main menu.
(You will need to include java.Math.* and use floating point input for this exercise.)
The wind chill index (WCI) is calculated from the wind speed v
in miles per hour and the temperature t
in Fahrenheit. Three formulas
are used, depending on the wind speed:
if (0 <= v <= 4) then WCI = t if (v >=45) then WCI = 1.6t - 55 otherwise, WCI = 91.4 + (91.4 - t)(0.0203v - 0.304(v)1/2 - 0.474)
To calculate (v)1/2
use
Math.sqrt( double )
.