DUE: Tuesday, May 4 before 11:00pm
Collaboration is strictly FORBIDDEN. Programs must represent YOUR OWN original work. Sharing code or team-coding are not allowed for this assignment. Copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is not allowed. Cooperation to the extent of helping to debug, or discussing the general approach to solving the problem is encouraged, but should never involve communicating code or even pseudo-code or explicit algorithms. Your code must be unique -- if it is not, we will find out, and will treat it as a case of flagrant academic dishonesty.
You must turn in a C++ source file (and only a C++ source file). The name for your source file should be as4.cpp.
Turn in online to the appropriate folder for your lab section (e.g., as4_sec20 for students enrolled in lab section 20). If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).
Remember to include the header as it is in the template provided on the class website.
Write a program that prints pictures of numbers. The program should ask the user for an integer between 0 and 9999. It should then print out a picture of each digit of that number. Your program should allow the user to keep entering new numbers to be drawn out until they wish to stop. You may draw the picture of each digit using any character you like. For example, if the user inputs the number 1234, your program would output something like the following:
* * * * * ** * * * * **** ** * * * * * ** * * * * **** * *
You may draw your digits any way you like as long as we can tell what they are. Also, you may draw leading zeros if the number entered is less than 4 digits.
You are required to use one or more functions in a useful way. You must also do some error checking on the input. For example, you should not allow the user to input a number less than 0 or greater than 9999. You must NOT use global variables. You should pass in the variable(s) as formal parameter(s).
Breaking up the number 1234 into individual digits:
1234 / 1000 using integer division gives you 1 (the first digit to draw)
1234 % 1000 gives you 234 (the rest of the digits)
234 / 100 gives you 2 (the next digit you want to draw)
234 % 100 gives you 34 (the rest of the digits)
34 / 10 gives you 3 (the next digit you want to draw)
34 % 10 gives you the 4 (the last digit you want to draw)
Breaking up the number 405 into individual digits:
405 / 1000 using integer division gives you 0 (the first digit to draw)
405 % 1000 gives you 405 (the rest of the digits)
405 / 100 gives you 4 (the next digit you want to draw)
405 % 100 gives you 5 (the rest of the digits except the leading 0)
5 / 10 gives you 0 (the next digit you want to draw)
5 % 10 gives you 5 (the last digit you want to draw)
For 1 pt BONUS, do NOT print the leading zeros if the number is less than 4 digits.
If the program does not compile, 5 pts will be deducted from the final score. Compile your code often. Only write a small portion of code before checking that it still compiles. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.
1 pt: Correct cout statements for each digit
1 pt: Input error checking (Only values between 0 and 9999 are allowed)
3 pts: Correct logic
- (1 pt) if structure to determine which digit to draw
- (1 pt) breaks up number to individual digits
- (1 pt) misc (e.g., allows user to repeat)
3 pts: Functions
- (2 pts) DOES NOT USE GLOBAL VARIABLES
- (1 pt) uses 1 or more functions
2 pts: Style
- (.5 pts) Good variable names
- (.5 pts) Proper indentation/spacing
- (.5 pts) Good comments (including header info)
- (.5 pts) No line wraps