The video game machines at your local arcade output coupons depending on how well you play the game. You can redeem 10 coupons for a candy bar or 3 coupons for a gumball. You prefer candy bars to gumballs. Write a program that inputs the number of coupons you win and outputs how many candy bars and gumballs you can get if you spend all of your coupons on candy bars first and any remaining coupons on gumballs.
Program:
#include <iostream>
using namespace std;
int main()
{
const int COUPONS_PER_CANDYBAR = 10;
const int COUPONS_PER_GUMBALL = 3;
int numbeOfCouponsWin = 37;
int numberOfCandybars = numbeOfCouponsWin / COUPONS_PER_CANDYBAR;
int remainingCoupons = numbeOfCouponsWin % COUPONS_PER_CANDYBAR;
int numberOfGumballs = remainingCoupons / COUPONS_PER_GUMBALL;
remainingCoupons = remainingCoupons % COUPONS_PER_GUMBALL;
cout << "Number of coupons win: " << numbeOfCouponsWin << endl;
cout << "Number of candy bars get: " << numberOfCandybars << endl;
cout << "Number of gumballs get: " << numberOfGumballs << endl;
cout << "Number of remaining coupons: " << remainingCoupons << endl;
return 0;
}
Output:
Number of coupons win: 37
Number of candy bars get: 3
Number of gumballs get: 2
Number of remaining coupons: 1