Question

In: Computer Science

using Visual Studio write a code containing a main() program that implements the coin change state...

using Visual Studio write a code containing a main() program that implements the coin change state machine in C++ according to the guidance given in Translating a state machine to C++ Test your code using prices 1 and 91 cents, and assume change is calculated from a dollar bill. Copy and paste your console output to a text editor and save the result in a single file named console.txt. Upload your exercise081.cpp and console.txt files to Canvas.

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

#include<iostream>
using namespace std;

int main(){
  
   int cents,copy;
   int quarters,dimes,nickels,pennies;
  
  
   cout<<"Enter cents [1-91]: ";
   cin >> cents;
   copy =cents;
  
   quarters = cents/25; cents%=25;
   dimes = cents/10; cents%=10;
   nickels = cents/5; cents%=5;
   pennies = cents;
  
   cout<<"Here is the change for "<<copy<<" cents:\n";
  
   if(quarters!=0)
   cout<<quarters<<" quarter coin(s).\n";
  
   if(dimes!=0)
   cout<<dimes<<" dime coin(s).\n";
  
   if(nickels!=0)
   cout<<nickels<<" nickel coin(s).\n";
  
   if(pennies!=0)
   cout<<pennies<<" penny coin(s).\n";
  
  


   return 0;
}

===================================================================

Enter cents [1-91]: 87
Here is the change for 87 cents:
3 quarter coin(s).
1 dime coin(s).
2 penny coin(s).

--------------------------------
Process exited after 3.856 seconds with return value 0
Press any key to continue . . .

Enter cents [1-91]: 91
Here is the change for 91 cents:
3 quarter coin(s).
1 dime coin(s).
1 nickel coin(s).
1 penny coin(s).

--------------------------------
Process exited after 0.963 seconds with return value 0
Press any key to continue . . .


Enter cents [1-91]: 75
Here is the change for 75 cents:
3 quarter coin(s).

--------------------------------
Process exited after 4.069 seconds with return value 0
Press any key to continue . . .


Related Solutions

Create a Visual Studio console project (c++) containing a main() program that declares a const int...
Create a Visual Studio console project (c++) containing a main() program that declares a const int NUM_VALUES denoting the array size. Then declare an int array with NUM_VALUES entries. Using a for loop, prompt for the values that are stored in the array as follows: "Enter NUM_VALUES integers separated by blanks:" , where NUM_VALUES is replaced with the array size. Then use another for loop to print the array entries in reverse order separated by blanks on a single line...
write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from 0 to 100, computes the average of those scores and then writes out a letter grade using the typical grading scale. Your program will also: 1. Allow the user to enter any number of scores he or she wishes but assume there will be at least one score entered. 2. Use a sentinel-controlled loop variable to terminate the loop when the user has no...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a whole paragraph with punctuations (up to 500 letters) either input from user, initialize or read from file and provide following functionalities within a class: a)   Declare class Paragraph_Analysis b)   Member Function: SearchWord (to search for a particular word) c)   Member Function: SearchLetter (to search for a particular letter) d)   Member Function: WordCount (to count total words) e)   Member Function: LetterCount (ONLY to count all...
using code composer studio 1. write a program for the msp430fr6989 that will light LED1, whenever...
using code composer studio 1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It should turn off whenever S1 is released. 2. Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
Using the code below from “LStack.h” file, write the code for a main program that takes...
Using the code below from “LStack.h” file, write the code for a main program that takes as input an arithmetic expression. The program outputs whether the expression contains matching grouping symbols. For example, the arithmetic expressions { 25 + ( 3 – 6 ) * 8 } and 7 + 8 * 2 contains matching grouping symbols. However, the expression 5 + { ( 13 + 7 ) / 8 - 2 * 9 does not contain matching grouping symbols....
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT