Chapter 1 & 2 Exercises

Verified

Added on  2019/09/22

|4
|632
|353
Homework Assignment
AI Summary
This document presents solutions to selected exercises from Chapters 1 and 2 of an unspecified mathematics textbook. Chapter 1 includes solutions involving algorithms for ticket purchases and employee payroll calculations. These solutions are presented as step-by-step instructions, outlining the input, process, and output for each problem. Chapter 2 focuses on IPO (Input-Process-Output) charts, demonstrating their use in calculating total earnings from ticket sales and contributions to retirement savings. The solutions provide both the algorithm and example test cases to verify the correctness of the calculations. The exercises cover fundamental programming logic and problem-solving techniques within a mathematical context.
Document Page
Chapter 1
Exercise 6:
Steps:
1. Int flag = 0;
2. Char customer[100];
3. Int custOweAmt[100];
4. ask for total number of customers into nCust
5. for I = 1 to n ( loop will continue for n customer)
6. print: “enter name of customer”
7. take input for customer name into customer[i-1]
8. do loop begins
9. flag= 0;
10. print: “enter number of tickets less than or equal to 4”
11. take input for number of tickets
12. check number of tickets if greater than 4 then go to step 13 otherwise step 15
13. print: “You can purchase up to 4 tickets only.”
14. set flag = 1;
15. else
16. custOweAmt[i-1] = 4 * 35;
17. end if
18. while ( flag) [ if flag = 1 then go to step 5 else go to step 3]
19. end of loop
20. for I = 1 to n ( loop will continue for n customer)
21. print: customer name owed amount
22. print: customer[i-1] custOweAmt[i-1]
23. end of loop
Exercise 8:
Steps:
1. print: “Enter 5 employs details”
2. char emp_name[5];
3. int emp_work_hour[5];
4. float emp_pay_rate[5];
5. for I = 1 to 5 when I value reaches to 5 then go to step 13
6. print: “enter name”
7. name into emp_name[i-1];
8. print: “enter total working hours”
9. hours into emp_work_hour[i-1]
10. print: “enter pay rate”
11. pay rate ino emp_pay_rate[i-1]
12. go to step 5 to enter details of next employee
13. for I = 0 to 4
14. work_hour = emp_work_hour[i]
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
15. Check: if work_hour > 40 then otherwise go to step 21
16. total_pay_rate = pay_rate[i]+ (pay_rate[i] / 2)
17. Print: name is : emp_name[i]
18. Print: regular pay is: pay_rate[i]
19. Print: overtime hours: work_hour – 40
20. Print: overtime pay: pay_rate[i] / 2
21. Print: gross pay: total_pay_rate
22. Else
23. Print: name is : emp_name[i]
24. Print: gross pay: pay_rate[i]
25. Go to step 13
26. End of for loop
Exercise 12:
Steps:
1. Repeat 3 times
Walk forward
End repeat
2. Turn left 9 degrees
Repeat 2 times
Walk forward
End repeat
3. Turn right 90 degrees
4. Repeat 3 times
Walk forward
End repeat
5. Trun 90 degree left
Walk forward
6. Turn 90 degree right
7. Repeat 4 times
Walk forward
End repeat
8. Turn right 180 degrees
9. Sit down
Document Page
Chapter 2
Exercise 6:
Steps:
IPO Chart
Input Process Output
the number of first-class tickets sold Number of tickets * Cost per
ticket
Total amount earned by first class
tickets
the number of coach tickets sold Number of tickets * Cost per
ticket
Total amount earned by coach
tickets
Testing of IPO Chart
Input Process Output
9 9 * 125 = $1125 $1125
52 52 * 90 = $4680 $4680
Total earned amount $1125 + $4680 = 5805 $5805
Document Page
Exercise 10:
Steps:
IPO Chart
Input Process Output
Calculate Annual salary Monthly salary * paycheck Total annual salary
Calculate employee percent rate
contribution
Percent rate * annual salary Total amount saved by employee
Calculate employer percent rate
contribution
Percent rate * annual salary Total amount saved by employer
Testing of IPO Chart
Input Process Output
$1465 1465 * 24 $35160
4% of salary 4% of35160 = $1406.4 $1406.4
2% of salary 2% of35160 = 5805 $703.2
chevron_up_icon
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]