Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(int argc, const char * argv[])
- {
- cout.setf(ios::fixed);
- cout.setf(ios::showpoint);
- cout.precision(2);
- int userinput;
- cout << "A packet of candie costs $1.50. You have inserted $0.00. Please insert coins:";
- cin >> userinput;
- switch (userinput)
- {
- case 'n':
- {
- userinput = 0.05;
- break;
- }
- case 'd':
- {
- userinput = 0.10;
- break;
- }
- case 'q':
- {
- userinput = 0.25;
- break;
- }
- case 'D':
- {
- userinput = 1.00;
- break;
- }
- default:
- {
- cout << "'" << userinput << "' is not a valid coin.";
- }
- break;
- }
- int i;
- for (i = 0; i <= userinput; i++)
- {
- cout << "A packet of candie costs $1.50. You have inserted $" << userinput << ".";
- cout << "Please insert coins: ";
- cin >> userinput;
- userinput = userinput + userinput;
- }
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement