1.

Solve : C++ if - else?

Answer»

I am trying to make this program work and it is not printing - COINS PER DOLLAR CALCULATION will not print. Help, Please.

using std::COUT;
using std::cin;
using namespace std;

;int money;
#define cents_per_dollar   100
#define pennies_per_dollar 100
#define nickels_per_dollar  20
#define dimes_per_dollar    10
#define quarters_per_dollar  4


;int main()//program converts dollars to coins;
{
  int money;   
  const int PENNY = 1;
  const int NICKEL = 5;
  const int DIME = 10;
  const int QUARTER = 25;
  const int DOLLAR = 100;
  int coin;
  int total;
 
  std::cout << " Please enter number: ";
  std::cin >> money
  ; // display number
 
    cout << "choose PENNY, NICKEL, DIME, QUARTER, enter\n"; //display message
   cin >> coin ;
   
/* Coins per Dollar Calculations */
{      
     if (coin == PENNY);
      cout << ("money * 100= PENNY/DOLLAR");  }
       you have SYNTAX errors everywhere, fix them up

also your program seems fairly simple so just use full head

#include
using namespace std;

instead of

using std::cout;
using std::cin;
using namespace std;
Dont really get the program but here's a WORKING version of the CODE Code: [Select]#include <iostream>
using namespace std;

int money;
#define cents_per_dollar   100
#define pennies_per_dollar 100
#define nickels_per_dollar  20
#define dimes_per_dollar    10
#define quarters_per_dollar  4


int main()//program converts dollars to coins;
{
  int money;   
  const int PENNY = 1;
  const int NICKEL = 5;
  const int DIME = 10;
  const int QUARTER = 25;
  const int DOLLAR = 100;
  int coin;
  int total;
 
  cout << " Please enter number: ";
  cin >> money;
   // display number
 
    cout << "choose PENNY, NICKEL, DIME, QUARTER, enter\n"; //display message
   cin >> coin;
   
/* Coins per Dollar Calculations */   
     if (coin == PENNY);
      cout << money * 100 << "= PENNY/DOLLAR";
}



Discussion

No Comment Found