CPPForSchool.com: Variable, Operator & Expression Set 2: Assignment 3
3.
Write a program which accepts amount as integer and display total number of Notes of Rs. 500, 100, 50, 20, 10, 5 and 1.
For example, when user enter a number, 575,
the results would be like this...
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
1: 0
This assignment had me quite puzzled. I was not exactly sure what "total number of Notes of Rs" meant so I had to research it. Unfortunately, there weren't any examples available that distinctly worded it the same way. With that said, I decided to take a plunge into the sample solution code. Once I reviewed the sample source code, I quickly understood what "total number of Notes of Rs" meant. Ultimately, I needed to create a program that would take an integer and output the number of times 500, 100, 50, 20, 10, 5, and 1 divided into the integer.
In order to accomplish this task, I had to first divide the integer each Note. From there, the remainder would be divided using the modulo operator relay the remainder onto the next dividing number. For example, if the user inputted 324. The program would first attempt to divide by 500. It will then output a 0, divide by modulo 500, which the value would be copied onto the next variable. See source code below.
Now that the source has been completed, I tested it with the example integer. That way, I can ensure that it is working as designed.
Once the example integer was confirmed, I immediately tested the program with a different integer.
For example, when user enter a number, 575,
the results would be like this...
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
1: 0
This assignment had me quite puzzled. I was not exactly sure what "total number of Notes of Rs" meant so I had to research it. Unfortunately, there weren't any examples available that distinctly worded it the same way. With that said, I decided to take a plunge into the sample solution code. Once I reviewed the sample source code, I quickly understood what "total number of Notes of Rs" meant. Ultimately, I needed to create a program that would take an integer and output the number of times 500, 100, 50, 20, 10, 5, and 1 divided into the integer.
In order to accomplish this task, I had to first divide the integer each Note. From there, the remainder would be divided using the modulo operator relay the remainder onto the next dividing number. For example, if the user inputted 324. The program would first attempt to divide by 500. It will then output a 0, divide by modulo 500, which the value would be copied onto the next variable. See source code below.
Now that the source has been completed, I tested it with the example integer. That way, I can ensure that it is working as designed.
Once the example integer was confirmed, I immediately tested the program with a different integer.
Comments
Post a Comment