0% found this document useful (0 votes)
118 views

Sam and Ella's Delicatessen Wants You To Write A Program To Take Orders From The

The document contains several programming problems and their solutions. It asks the user to write programs that: 1) Calculate a user's age based on their birth year and current year input. 2) Calculate the discounted price of purchases over $10 with a 10% discount. 3) Take orders for items including price, shipping costs of $2-$3, and adding $5 for overnight shipping. 4) Calculate the sum of 1/n from 1 to a user-input N. 5) Calculate the sum of squares and cubes of integers from 1 to a user-input N using a single loop. 6) Calculate shipping costs for mail orders based on weight, with $3 handling fee and

Uploaded by

Man Runner
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views

Sam and Ella's Delicatessen Wants You To Write A Program To Take Orders From The

The document contains several programming problems and their solutions. It asks the user to write programs that: 1) Calculate a user's age based on their birth year and current year input. 2) Calculate the discounted price of purchases over $10 with a 10% discount. 3) Take orders for items including price, shipping costs of $2-$3, and adding $5 for overnight shipping. 4) Calculate the sum of 1/n from 1 to a user-input N. 5) Calculate the sum of squares and cubes of integers from 1 to a user-input N using a single loop. 6) Calculate shipping costs for mail orders based on weight, with $3 handling fee and

Uploaded by

Man Runner
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

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.
======================================================
Sam and Ella's Delicatessen wants you to write a program to take orders from the
Internet. Your program asks for the item, its price, and if overnight shipping is wanted.
Regular shipping for items under $10 is $2.00; for items $10 or more shipping is $3.00.
For overnight delivery add $5.00.
Enter 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
(Use our ordinary IO methods. A real Internet order form would use different I/O methods, but ignore this.)
Write a program that computes the following sum:
sum = 1.0/1 + 1.0/2 + 1.0/3 + 1.0/4 + 1.0/5 + .... + 1.0/N
N will be an integer limit that the user enters.
Enter N
4

Sum is: 2.08333333333


=================================================
Write a program that adds up the squares and adds up the cubes of integers from 1 to N,
where N is entered by the user:
Upper Limit:
5
The sum of Squares is 55
The sum of Cubes is 225
Do this by using just one loop that generates the integers. Of course, if you really needed
to calculate these sums you would use the appropriate formulas:
12 + 22 + 32 + ... + n2 = n(n+1)(2n+1)/6
13 + 23 + 33 + ... + n3 = n2(n+1)2/4
Add these formulas to your program and print out their results as well as that of the
explicit summations
A mail order company charges $3.00 for handling, free shipping for orders 10 pounds or
less, plus $0.25 for each pound over 10. Write a program that repeatedly asks the user for
the weight of an order, then writes out the shipping charge. The program stops when a
weight of zero or less is entered.
Weight of Order:
5
Shipping Cost: $3.00
Weight of Order
20
Shipping Cost: $5.50
Weight of Order
0
bye

You might also like