CSIS 10A Assignment 2 10 Points

advertisement
CSIS 10A
Assignment 2
10 Points
Read: Hennefeld, Chapter 3
Due: Start of class, next week
Complete the problems in Lab2MoreBasics.cpp for up to 11 points (1 pt Extra
Credit) When you are finished, print out the file and turn it in. Store this handout
(and graded labs) in your binder for future reference.
Problems 1 – 8 are worth 10 points. Challenge students may want to do 7 - 10.
DRILL EXERCISES Notes on selected problems
2. Code the following formula for calculating Force (should get Force = 1078.4 )
4. The volume of a sphere is
However, instead of getting 4.18667 this program gives 3.14. What’s wrong?
Fix the program, then modify it to use the constant PI in the formula
PROGRAM TEST PLANS (User input is underlined)
Problem 7. Write a program that converts a weight from kilograms to pounds
(1 kg = 2.2 lbs)
Test Run #1
Enter number of kilograms 1
1 kg = 2.2 pounds
Test Run #2
Enter number of kilograms 6
6 kg = 13.2 pounds
Problem 8. Write a program that inputs how many quarters and dimes you have
and prints out the total value in dollars. (Optional—use output formatting for
currency values, see p42)
Test Run #1
Enter number of quarters & dimes 0 5
Total is $0.50
Test Run #2
Enter number of quarters & dimes 5 2
Total is $1.45
Problem 9. Write a program that converts ounces into pounds and ounces (use
integer division and % operator)
Test Run #1
Enter number of ounces 12
0 lb and 12 oz
Test Run #2
Enter number of ounces 35
2 lb and 3 oz
Download