tailieunhanh - C++ Lab 2 Sending the output to a printfile Data Types: Chapter 2

After the first laboratory assignment several students came to my office and asked questions that were very similar. Thus, this addendum to Chapter 1 was written. When a program is assigned to you the first thing you should do is to understand the problem. Even though you may think that the assignment is very easy and you can do it at the last minute, most of the time this is not the case. Therefore, I require you to solve the problem assigned to you with "paper and pencil" first. If you approach me or the graduate assistant for help with a programming problem, you will be asked show this handwritten work first. If. | CHAPTER 2B PROGRAMMING TIP After the first laboratory assignment several students came to my office and asked questions that were very similar. Thus this addendum to Chapter 1 was written. When a program is assigned to you the first thing you should do is to understand the problem. Even though you may think that the assignment is very easy and you can do it at the last minute most of the time this is not the case. Therefore I require you to solve the problem assigned to you with paper and pencil first. If you approach me or the graduate assistant for help with a programming problem you will be asked show this handwritten work first. If you do not have it we will not help you with the coding. We will still help you to understand the problem. Once you understood the problem figure out all the functions and variables needed to write the program. Make a structure chart and show the data flow. Next write the psuedocode for each of the modules. A structure chart tells you what to do a psuedocode tells you how to do it. I will cover this in class at great detail. Here is an example of a programming assignment. Write a program to determine how many quarter rolls dime rolls nickel rolls and penny rolls in a given amount of dollars. Let us understand this problem. What are the known information about this programming assignemnt There are ten dollars in a quarter roll. There are five dollars in a dime roll. There are two dollars in a nickel roll. And there are two penny rolls in a dollar. The amount may vary each time you run the program. For this example let us assume the amount is 38 dollars. Quarter rolls may be obtained by doing integer division 38 10. Integer division gives you only the integer portion of the 3 quarter rolls. Remainder is 38-30 which is 8. You can get the remainder by doing the modulus operation. Dime rolls may be obtained by doing integer division 8 5--------- 1 dime roll. The remainder is 8-5 whch is 3. Nickel rolls may be obtained by doing .

TỪ KHÓA LIÊN QUAN