This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:spring2017:cprog:projects:sof0 [2017/01/23 21:13] – [Reflection] wedge | haas:spring2017:cprog:projects:sof0 [2017/01/31 21:25] (current) – [Program] wedge | ||
---|---|---|---|
Line 15: | Line 15: | ||
The allure of using (and learning) a programming language is to be able to effectively use it to solve problems, which in and of themselves are simulations of some process we can do in "the real world" | The allure of using (and learning) a programming language is to be able to effectively use it to solve problems, which in and of themselves are simulations of some process we can do in "the real world" | ||
- | In this case, we will be writing a program which will implement the mental math techniques for computing the square of any two-digit number that ends with 5. | + | In this case, we will be writing a program which will implement the mental math techniques for computing the square of any one, two-, or three-digit number that ends with 5. |
=====Background===== | =====Background===== | ||
Line 116: | Line 116: | ||
* display the final value (output) | * display the final value (output) | ||
* display the beginning and ending parts together (but stored in separate variables) | * display the beginning and ending parts together (but stored in separate variables) | ||
- | * display the resulting number to STDOUT | + | * display the resulting number to STDOUT |
- | * display any supporting text to STDERR | + | * display any supporting text to STDERR |
+ | * because we have not officially learned how to do selection/ | ||
=====Execution===== | =====Execution===== | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
Enter value: 75 | Enter value: 75 | ||
- | 75 x 75 = 5625 | + | 75 x 75 = |
- | lab46: | + | lab46: |
</ | </ | ||
The execution of the program is short and simple- obtain the input, do the processing, produce the output, and then terminate. | The execution of the program is short and simple- obtain the input, do the processing, produce the output, and then terminate. | ||
+ | Note how the two " | ||
+ | Similarly, here's an example of 105x105: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | Enter value: 105 | ||
+ | 105 x 105 = 11025 | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | The ' | ||
+ | |||
+ | If you'd like to verify successful output to STDOUT/ | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | 11025 | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | What we are doing here is two-fold: | ||
+ | |||
+ | * We are using command-line I/O redirection to redirect STDERR (which is bound to file descriptor #2) to the system bit-bucket. | ||
+ | * We are " | ||
+ | |||
+ | Similarly, if we were to eliminate STDOUT entirely (for verifying STDERR output): | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | Enter value: 75 | ||
+ | 75 x 75 = lab46: | ||
+ | </ | ||
+ | |||
+ | What we are doing here: | ||
+ | |||
+ | * We are using command-line I/O redirection to redirect STDOUT (which is bound to file descriptor #1) to the system bit-bucket. | ||
+ | |||
+ | =====Verification===== | ||
+ | One of the tests I will perform for output compliance of your code will involve comparing your program' | ||
+ | |||
+ | I will make use of a checksum to verify exactness. | ||
+ | |||
+ | You will need to run this from your sof0 project directory with a compiled and operational binary by the name of **sof0**. | ||
+ | |||
+ | You can check your project by typing in the following at the prompt: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | If all aligns, you will see this: | ||
+ | |||
+ | <cli> | ||
+ | ================================================== | ||
+ | = CPROG sof0 project output validation tool = | ||
+ | ================================================== | ||
+ | sof0 checksum is: 822a47fb2a45845500b6c10878045bd5 | ||
+ | your checksum is: 822a47fb2a45845500b6c10878045bd5 | ||
+ | ================================================== | ||
+ | verification: | ||
+ | ================================================== | ||
+ | </ | ||
+ | |||
+ | If something is off, your checksum will not match the sof0 checksum, and verification will instead say " | ||
+ | |||
+ | <cli> | ||
+ | ================================================== | ||
+ | = CPROG sof0 project output validation tool = | ||
+ | ================================================== | ||
+ | sof0 checksum is: 822a47fb2a45845500b6c10878045bd5 | ||
+ | your checksum is: 92af264c86823a61529948caaeac53e0 | ||
+ | ================================================== | ||
+ | verification: | ||
+ | ================================================== | ||
+ | </ | ||
+ | =====Questions / Food for Thought===== | ||
+ | These are things I'd like you to contemplate, | ||
+ | |||
+ | * Why/how does this trick work for 1-digit numbers? | ||
+ | * Considering our 1-, 2-, and 3-digit domain restriction for this project, how many candidate values are there for input? | ||
+ | * What is the smallest input value? | ||
+ | * What is the largest input value? | ||
+ | * How many input values are there that end in **5**? | ||
+ | * What is the largest square that can be calculated given the project input restrictions? | ||
+ | * How many digits is the largest square? | ||
+ | * How can knowing how many digits the largest square is help you implement your solution? | ||
=====Submission===== | =====Submission===== | ||
To successfully complete this project, the following criteria must be met: | To successfully complete this project, the following criteria must be met: | ||
Line 135: | Line 222: | ||
* Code must compile cleanly (no warnings or errors) | * Code must compile cleanly (no warnings or errors) | ||
* Executed program must display a total of 2 lines, one for input, one for output. | * Executed program must display a total of 2 lines, one for input, one for output. | ||
+ | * The computed number must be output to STDOUT | ||
+ | * Any supporting output must be output to STDERR | ||
+ | * Output is formatted in the manner in the sample above | ||
* Output must be correct, and match the form given in the sample output above. | * Output must be correct, and match the form given in the sample output above. | ||
- | * Code must be nicely and consistently indented | + | * Code must be nicely and consistently indented |
* Code must implement solution using the mental math technique described above | * Code must implement solution using the mental math technique described above | ||
* Code must be commented | * Code must be commented | ||
Line 144: | Line 234: | ||
* Track/ | * Track/ | ||
* 25% late penalty per day after deadline | * 25% late penalty per day after deadline | ||
+ | * Program is submit in a C source file called **sof0.c** and compiles without warning, note, nor error with gcc on lab46. | ||
* Submit a copy of your source code to me using the **submit** tool. | * Submit a copy of your source code to me using the **submit** tool. | ||
Line 149: | Line 240: | ||
<cli> | <cli> | ||
- | $ submit cprog mms0 squares.c | + | $ submit cprog sof0 sof0.c |
- | Submitting cprog project "squares": | + | Submitting cprog project "sof0": |
- | -> squares.c(OK) | + | -> sof0.c(OK) |
SUCCESSFULLY SUBMITTED | SUCCESSFULLY SUBMITTED | ||
Line 157: | Line 248: | ||
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | ||
+ | |||
+ | I'll be looking for the following: | ||
+ | |||
+ | < | ||
+ | 52: | ||
+ | *: | ||
+ | *:sof0:data stored and calculated in correct and separate variables [4/4] | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *:sof0:no negative compiler messages for sof0.c [4/4] | ||
+ | </ |