Can anyone help me with what is wrong with the program? I cant get it to compile.
/* Dollar to Coin Conversion.c
Final Project */
#include <iostream>
using namespace std;
/* function main begins program execution */
int main( void )
{
const int pennies_per_dollar=100;
const int nickles_per_dollar=20;
const int dimes_per_dollar=10;
const int quarters_per_dollar=4;
int values={25,10,5,1},
int description={"quarter", "dime", "nickle", "penny"};
}
//declare variables
int dollarAmount;
newTotal;
selection;
cout<<"Please enter a dollar amount";//user asked for dollar value
cin>>dollarAmount;//user enters dollar amount
cout<<"Choose the coin denomination";//user asked to choose coin
cout<<"Pennies, Nickles, Dimes, Quarters";//user given options of coins
if (int dollarAmount<=1)
return -1;
else if (selection==pennies);{newTotal=dollarAmount*100}
else if (selection==nickles);{newTotal=dollarAmount*20}
else if (selection==dimes);{newTotal=dollarAmount*10}
else if (selection==quarters);{newTotal=dollarAmount*4;}
cout<<newTotal;
{
int main( void )
{
constint pennies_per_dollar=100;
constint nickles_per_dollar=20;
constint dimes_per_dollar=10;
constint quarters_per_dollar=4;
int values={25,10,5,1},
int description={"quarter", "dime", "nickle", "penny"};
}
Above is your main() function.
The rest is code which is not part of any function. It should be inside main, or inside some other function.
It ends with a trailing opening brace, which makes it look as though this is incomplete.
/* Dollar to Coin Conversion.c
Final Project */
#include <iostream>
using namespace std;
/* function main begins program execution */
int main( void )
{
const int pennies=1;
const int nickles=5;
const int dimes=10;
const int quarters=25;
int newTotal=0;//amount of money *100/coin
int values[]={25,10,5,1};
char description[]={"quarter", "dime", "nickle", "penny"};
//declare variables
int dollarAmount;
newTotal;
selection;
cout<<"Please enter a dollar amount";//user asked for dollar value
cin>>dollarAmount;//user enters dollar amount
cout<<"Choose the coin denomination";//user asked to choose coin
cout<<"Pennies, Nickles, Dimes, Quarters";//user given options of coins
if ( dollarAmount<=1)//if dollar amount is less or equal to one
return -1;
else if (selection==pennies)//if user selects pennies
return (newTotal=(dollarAmount*100)/pennies);
else if (selection==nickles)//if user selects nickles
return (newTotal=(dollarAmount*100)/nickles);
else if (selection==dimes)//if user selects dimes
return (newTotal=(dollarAmount*100)/dimes);
else if (selection==quarters)//if user selects quarters
return (newTotal=dollarAmount*100)/quarters);
cout<<newTotal;
return 0;
}