CSIS 10A Assignment 1 10 Points

advertisement
CSIS 10A
Assignment 1
Read: Hennefeld, Chapter 1 and 2
10 Points
Due: Start of class, next week
Complete the problems in Lab1Basics.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.
PROGRAM TEST PLANS (User input is underlined)
Problem 7. Write a program that converts yards to inches, in other words, input
yards, output inches:
Test Run #1
Enter number of yards 4
4 yards = 144 inches
Test Run #2
Enter number of yards 6
6 yards = 216 inches
Problem 8. Write a program that can be used to calculate an employee paycheck.
Your programs should input two numbers: the number of hours worked and the
hourly rate. Only enter integer values.
Test Run #1
Enter hours and rate 40 10
pay = $400
Test Run #2
Enter hours and rate 10 7
pay = $70
Problem 9. Write a program that asks the user to input a length and width of a
rectangle. The program should then calculate and output both the area and
perimeter. Use the formulas:
area = length x width
perimeter =2 x (length + width)
Test Run #1
Enter the length and width 3 5
Area = 15 and Perimeter = 16
Test Run #2
Enter the length and width 7 9
Area = 63 and Perimeter = 32
Basic Interactive Program Structure (use for problems 7 – 9)
1)
2)
3)
4)
5)
Declare Variables
Ask (prompt using cout) for data
Input data (using cin)
Calculate result
Display result with message (using cout)
Download