Exercise Set#4

on Sunday, February 7, 2010
Exercise 1 --- Internet Delicatessen
Sam and Ella's Delicatessen wants a program to take orders from the internet. The program will accept item the user wants, its price, and will ask if the user wants overnight shipping. Regular shipping for items under $10 is $2.00; for items $10 or more shipping is $3.00. For overnight delivery add $5.00.

The item: Tuna Salad
Enter the price: 450
Overnight delivery (0==no, 1==yes): 1

Invoice:
Tuna Salad 4.50
shipping 7.00
total 11.50

Exercise 2 --- Steam Engine Efficiency
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 accept  air temperature and the steam temperature and writes 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.

Exercise 3 --- Microwave Oven
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 accepts the number of items and the single-item heating time. The program then writes out the recommended heating time.

Hint: do this with four successive single-branch if statements each of which tests for one of the four cases: 1 item, 2 items, 3 items, more than three items.

Exercise 4 --- Fantasy Game
In a new role-playing fantasy game players get to design their character by picking a point value for each of three characteristics:

Strength, from 1 to 10
Health, from 1 to 10
Luck, from 1 to 10

Write a program that accepts a name for the character and asks for the point value of for each of the three characteristics. However, the total points must be less than 15. If the total exceeds 15, then 5 points are assigned to each characteristic
Welcome to Ever's Quest
Enter the name of your character: Sunny
Strength (1-10): 8
Health (1-10): 4
Luck (1-10): 6

You have give your character too many points! Default values have been assigned:

Chortle, strength: 5, health: 5, luck: 5

2 comments:

ŇÃŜĮŘ ÃββÃŜ said...

Nys Blog
For More programming exercises ,visit this blog
programmingexercises

niazi said...

This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

Love from

Post a Comment