Return to site

C++ programming help again...? | Yahoo Answers

The video game machines at your local arcade output couponsdepending on how well you play the game. You can redeem 10 coupons for a candybar or 3 coupons for a gumball. You prefer candy bars to gumballs. Write aprogram that inputs the number of coupons you win (you can test with 9, 28, 37coupons), 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.

I have the candy bars correct i just have no idea on how to complete the other 2

the output should look like this:

- Sample Tommy Hilfiger Coupon output with 37 coupons:

Please enter number of coupons: 37

Number of Candy bar = 3

Number of Gumballs = 2

Remaining coupons = 1

I have gotten this far but this is not correct once again:

#include <iostream>



using namespace std;

#define NEWLINE 'n'

int main ()





int number;



const int candybar_cost = 10;



const int gumball_cost = 3;



int coupons_left = number % 10;



int num_gumballs = coupons_left %= 3;

cout <<" Please enter a number of coupons ";



cin >> number;



cout << NEWLINE;



cout <<"Number of Candy Bars " << (number / candybar_cost);



cout << NEWLINE;



cout <<"Number of Gumballs " << coupons_left % gumball_cost;



cout << NEWLINE;



cout <<"Remaining Coupons " << num_gumballs;

system ("PAUSE");



return 0;