I need help declaring values

I'm in a beginners programming class and we have not went over a lot being that school just started less than 3 weeks ago, but can someone help me declare the values of the the dimes and quarters in my program. The purpose of it is to add up the total number in cents while at the same time making sure the program is universal to be used with different numbers.

Here is my code.

//Airamis Hargrove
// CSCI 1010 Section 3
// Pass 2 program
//Jan 31, 2013
/*Take the number of dimes and quarters and get the total ammount of cents*/

#include <iostream>
using namespace std;

int main ( )
{ int dimes,quarters,result,amount_1,amount_2

int result;

cout<<"Welcome to Hargrove's cents calculator"<<endl;
cout<<"Enter the number of dimes"<<endl;
cout<<"Enter the number of quarters"<<endl;
cin>>dimes;
cin>>quarters;
result = dimes*quarters;

cout<<"The total cents in dimes and quarters is"<<endl; result;




system ("pause");
return 0;

}



If there are any problems with my code please feel free to criticize my code as need be.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Airamis Hargrove
// CSCI 1010 Section 3
// Pass 2 program
//Jan 31, 2013
/*Take the number of dimes and quarters and get the total ammount of cents*/

#include <iostream>

int main ( )
{
    using namespace std;
    
    const double DIME_VAL = .10;
    const double QUARTER_VAL = .25;
    int dimes, quarters;
    double result;

    cout << "Welcome to Hargrove's cents calculator"<<endl;

    cout << "Enter the number of dimes"<<endl;
    cin >> dimes;

    cout << "Enter the number of quarters"<<endl;
    cin >> quarters;
    result = dimes * DIME_VAL + quarters * QUARTER_VAL;

    cout<<"The total cents in dimes and quarters is " << result << endl;


    system ("pause");
    return 0;

}


Your were on the right track. Take a look at this code and tell me if its to yours satisfaction. You should take a good look at the c++ tutorial on the site or get yourself a good c++ book.
Last edited on
Thanks you so much. A few of the operators that you used we actually have not went over yet but the with a few changes i got it the way i needed. Thanks for the help.

Same problem for me but i dont want to copy/paste the correct source code because then ill just be back here next week with another issue. Can someone help me by pointing out my errors so far and most importantly, explain how/where to write the statement that calculates the final result. That is really the problem that has caught me up so far and I think any other errors I have made have been the result of tinkering.

#include<iostream>
using namespace std;
int main( )
{
int dimes;
int quarters;
int cents;
int cents_val=1;
int dimes_val=10;
int quarters_val=25;

cout<<"Welcome To Orion's Cents Calculator"<<endl;
cout<<"Enter the number of dimes"<< endl;
cin>>dimes;
cout<<"Enter the number of quarters"<< endl;
cin>>quarters;

cout<<"Total cents in dimes and quarters is: "<<cents<<endl;
system ("pause");
return 0;

}
First error, dimes_value and etc. If you have a constant, you need to have that in code.

second, cout<<"Total cents in dimes and quarters is: "<<cents<<endl;

the computer doesn't know what cents is. you need to do what it is made of.

which is then made of dimes and quarters in turn are made by doing 10 * number of dimes + 25 * number of quarters.
Topic archived. No new replies allowed.