Help, im a student that has to write a program for counting coins. Half of the program works but the other half doesn.t
should have the following parameters.
output is:
Name
Date
total number of coins
number of quarters
number of dimes
nickels
pennies
I got all that to work but that math doesnt work
for the Value of the coins and the total coin value, can someone please tell me what im doing wrong?
#include <iostream> //----->Header file
#include <string.h>
#include <math.h>
void main()
{
double quarter_value(0.25);
double dime_value(0.10);
double nickel_value(0.05);
double pennies_value(0.01);
int num_quarters;
int num_dimes;
int num_nickels;
int num_pennies;
int total_num_coins;
int total_val_coins = quarter_value + dime_value + nickel_value + pennies_value;
int total_quarter_val = quarter_value * num_quarters;
int total_dime_val = dime_value * num_dimes;
int total_nickel_val = nickel_value * num_nickels;
int total_pennies_val = pennies_value * num_pennies;
char full_name[32],
date[12];
cout << "Please Enter Your Name: ";
cin >>full_name;
cout <<endl;
cout << "Please Enter Today's Date: ";
cin >>date;
cout <<endl;
cout << "Enter the Number of Quarters: ";
cin >>num_quarters;
cout <<endl;
cout << "Enter the Number of Dimes: ";
cin >>num_dimes;
cout <<endl;
cout << "Enter the Number of Nickels: ";
cin >>num_nickels;
cout <<endl;
cout << "Enter the Number of Pennies: ";
cin >>num_pennies;
cout <<endl;
//Total Number of Coins and Value
//total_num_coins=num_quarters+num_dimes+num_nickels +num_pennies;
//total_val_coins=quarter_value+dime_value+nickel_va lue+pennies_value;
//Total of each coin
//total_quarter_val= quarter_value*num_quarters;
//total_dime_val=dime_value*num_dimes;
//total_nickel_val=nickel_value*num_nickels;
//total_pennies_val=pennies_value*num_pennies;
cout <<"Name:" << full_name <<endl <<endl;
cout <<"Date:" << date <<endl <<endl;
cout <<"Total number of coins input:" << total_num_coins <<endl;
cout <<"Number of Quarters:" << num_quarters <<endl;
cout <<"Number of Dimes:" << num_dimes <<endl;
cout <<"Number of Nickels:" << num_nickels <<endl;
cout <<"Number of Pennies:" << num_pennies <<endl <<endl;
cout <<"Value of Coins:" <<endl;
cout <<"Quarters:" << total_quarter_val <<endl;
cout <<"Dimes:" << total_dime_val <<endl;
cout <<"Nickels:" << total_nickel_val <<endl;
cout <<"Pennies:" << total_pennies_val <<endl <<endl;
cout <<"Total Value of coints:" <<total_val_coins <<endl <<endl;
return 0;
}