Basic Java
$30-250 SGD
货到付款
Question 1
Restaurant sales tax in Malaysia is 6% and service charge is 10%. Write a program that accepts a price on the command line and prints out the appropriate tax and total purchase price.
(4 marks)
Question 2
Modify Question 1 program to accept an arbitrary number of prices (THREE prices), total them, calculate the restaurant sales tax, service charge and print the total amount.
(4 marks)
Question 3
a. Create a menu to prompt user enter their selection (1 for “ Convert Inches to Centimeters”, 2 for “ Convert Centimeters to Inches”, 3 for “Convert Grams to Kilograms”, and 4 for “Convert Kilograms to Grams”)
b. If user selects 1, write a program to prompt user enter a number of inches and converts it to centimeters. If user selects 2, write the inverse program that reads a number of centimeters from user and converts it to inches.
c. If user selects 3, write a program to prompt user enter a number of grams and converts it to Kilograms. If user selects 4, write the inverse program that reads a number of Kilograms from user and converts it to grams.
Note: You are required to identify the formulas.
(12 marks)
Question 4
Write a program that asks for the user's name and then writes her / his name to the screen with either "Ms." or "Mr." in front, depending if the name is for a female or male.
Assume that the only female names are:
• Mary
• Jessica
• Monica
Assume that the only male names are:
• Peter
• Wilson
• Johnson
(10 marks)
Question 5
During a special sale at a store, a 10% discount is taken on purchases over RM10.00. Write a program that asks for the amount of purchases, and then calculates the discounted price.
(5 marks)
Question 6
IKEA Malaysia wants a program to take orders from the internet. The program will ask ONE item the user wants, will ask its price, and will ask if the user wants overnight shipping. Regular shipping for items under RM10 is [url removed, login to view]; for items RM10 or more shipping is RM3.00. For overnight delivery add RM5.00. Your program should be able calculate the total price.
(10 marks)
Question 7
The maximum possible efficiency of a steam engine depends on the temperature of the steam in the boiler and the temperature of the outside air:
efficiency = 1 - Tair / Tsteam
where Tair is the air temperature and Tsteam is the steam temperature. The temperatures are give in degrees above absolute zero. Normal air temperature is about 300oK. Boiling is 373oK. Write a program that asks the user for the air temperature and the steam temperature and print out the maximum possible efficiency of a steam engine. However, if the steam temperature is less than 373oK there is no steam, so the efficiency is zero.
(10 marks)
Question 8
A microwave oven manufacturer recommends that when heating two items, add 50% to the heating time, and when heating three items double the heating time. Heating more than three items at once is not recommended. Write a program that asks the user for the number of items and the single-item heating time. The program then writes out the recommended heating time.
(10 marks)
Question 9
The front tires of a car should both have the same pressure. Also, the rear tires of a car should both have the same pressure (but not necessarily the same pressure as the front tires.) Write a program that prompt user enter pressure of the four tires and print a message to show whether the inflation is OK or not.
(7 marks)
Question 10
Although the pressures are the same in the tires, but the pressures must also within the range between 35 and 45. Modify the program in Question 9 and allow the system checks each tire’s pressure. If any of the tires is out of range, the program must able to print out an error message immediately.
(8 marks)
Question 11
A vendor company will give some discounts on it products based on the total units bought by the customer and the price of each unit. The table below shows the discount given with the price and the total units:
Number of the Price (RM)
items bought 0.01 – 10.00 10.01 – 100.00 100.01
1 - 9 0% 2% 5%
10 - 99 5 % 7% 9%
100 - 499 9% 15% 21%
500 – 999 14% 23% 32%
More than 1000 21% 32% 43%
Write a Java program to solve the above problem and display the price after the discount.
(20 marks)
项目ID: #960360