Question: Lab Assignment 2 Write a program that displays change due back to a customer. The display should print out the number of quarters, dimes, nickels,

Lab Assignment 2 Write a program that displays change due back to a customer. The display should print out the number of quarters, dimes, nickels, and pennies. Test your program using compile-time initialization of 97 pennies for the value to convert. Create a new project in Visual Studio or any IDE for your platform and name it FirstName_LastName_A2 where FirstName is your first name and LastName is your last name. Submit your zipped solution folder in Eagle online for grading. To solve this problem, we can identify IPO and develop the Pseudocode. 1. Input: Total pennies to convert, in this case, we are using 97 pennies 2. Processing: To convert the given pennies to quarters, dimes, nickels, and pennies in this order. 3. Output: Display the result for each denomination. 4. Variables: totalPennies, remainingPennies, quarters, dimes, nickels all are integer type 5. Constants: (See Note below) constants are not required, but might be helpful if you like flexible coding. PENNY_TO_QTR= 25, PENNY_TO_DIME=10, PENNY_TO_NICKEL=5 Detailed Pseudocode: 1. Prompt user to enter total pennies 2. Read user input and store value into totalPennies variable 3. We already know the conversion for each denomination, just need to write it down. a. Convert to quarters first, each quarter has 25 pennies, so we use quarters = totalPennies / 25 -- this calculation will give us total quarters. If you do create constant, you can use PENNY_TO_QTR instead of 25. (quarters = totalPennies / PENNY_TO_QTR) b. We need to figure out the remaining pennies after converting to quarter, so that we can convert the remaining pennies to dimes. remainingPennies = totalPennies % 25 -- use mod operator to calculate the remaining pennies dimes = remainingPennies /10 -- get total dimes from the remaining pennies c. We need to figure out the remaining pennies again, so that we can convert it to nickels; remainingPennies = remainingPennies % 10 -- use mod operator to calculate the remaining pennies nickels = remainingPennies / 5 -- get total nickels from the remaining pennies d. We just need to figure out the final remaining pennies remainingPennies = remainingPennies % 5 this will give us the final pennies. 4. Display quarters, dimes, nickels, and remainingPennies. Use the above detailed pseudocode to map to C# code in your project. **Note The following is not required, just for your reference. To improve the above solution, you can add constants to enhance your code. Constant is like variable, but with predefined value, and you cannot change the constant value during program execution. In our case, we already know the facts that one quarter = 25 pennies, one dime = 10 pennies, and one nickel = 5 pennies. So we can create constants for the exchange value instead of using 25, 10, and 5 in your code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!