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.
//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 ( )
{
usingnamespace std;
constdouble DIME_VAL = .10;
constdouble 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.
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;