HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.
-
Upload
jerome-wilson -
Category
Documents
-
view
228 -
download
0
Transcript of HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.
![Page 1: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/1.jpg)
HW1 Report
Xing Wang
![Page 2: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/2.jpg)
HW1-PR1 Question
![Page 3: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/3.jpg)
Not Good Formatted Example
![Page 4: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/4.jpg)
Perfect Answer
![Page 5: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/5.jpg)
HW1-PR2
• your program should read an operand, an operator as a single character +-*/, and another operand, separated by spaces. Output the results.
• For example: – 100 + 3.14 , output 103.14– 4 * 5, output 20
![Page 6: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/6.jpg)
HW1-PR2 Test CasesInput Output
1 + 2 3
1 - 2 -1
1 * 2 2
4 / 2 2
1 plus 2 2
1 minus 2 -1
1 mul 2 2
4 div 2 2
1.1 + 2.1 3.2
1 / 0 Warning : Divided by 0 is invalid.
![Page 7: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/7.jpg)
HW1-PR3
• Exercise 11 on page 86, but with the following modifications: instead of using U.S. currency, write your program for the Euro. Note that Euro coins come in different denominations from U.S. coins; there are 8 that you must account for. Report to the user the individual counts (as in the original problem) and the sum in Euros and cents (instead of dollars and cents). In addition, convert the final value to U.S. dollars using a recent exchange rate (do not worry about rounding the result, for now).
![Page 8: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/8.jpg)
HW1-PR3 Test CasesCent 1 Cent 2 Cent 5 Cent
10Cent 20
Cent 50
Euro 1 Euro 2 Total Euro
Total Dollar
1 2 1 0 0 0 0 0 0.1 0.136
0 0 0 3 1 1 0 0 1 1.36
0 0 0 0 0 0 4 3 10 13.6
3 1 1 2 1 1 0 0 1 1.36
1 2 1 0 2 1 1 4 10 13.6
3 6 7 9 3 4 2 2 10 13.6
36 27 86 55 79 47 22 14 100 136
585 630 807 394 284 116 511 138 1000 1360
4350 750 9408 4078 1214 6047 2567 1615 10000 13600
16749 85688 44799 14830 57099 57132 15652 19429 100100
136136
![Page 9: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/9.jpg)
HW1-PR4
![Page 10: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/10.jpg)
HW1-PR4 Signed Integer
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Max Integer : 2,147,483,647
1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1-1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Min Integer : -2,147,483,648
![Page 11: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/11.jpg)
The negative integer
• The absolute value of negative integer is the complementary of the binary representation plus 1.
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1-1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Complementary of -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1Absolute value of -1, Complementary of -1 plus 1
![Page 12: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/12.jpg)
HW1-PR4-Analysis 1
• 10^10 (1001010100000010111110010000000000 )
1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0
![Page 13: HW1 Report Xing Wang. HW1-PR1 Question Not Good Formatted Example.](https://reader035.fdocuments.us/reader035/viewer/2022080902/56649f4d5503460f94c6e076/html5/thumbnails/13.jpg)
HW1-PR4-Analysis 2
• 10^12, is a negative value as the sign bit is 1.1 1 1 0 1 0 0 0 1 1 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0