Hello ladies and gents!
This is my first post to the programming section. After reading through here, I've noticed that most of you guys are less than thrilled for someone to ask for some programming help with no input of their own, so you'll be happy to see that I've completed my own very simple code.
A bit about me: I'm 28 and just returning back to school to hopefully become a computer engineer. I'm taking my very first programming class which is C++. Mind you, I have no formal programming experience, other than what I have learned since the beginning of this semester. I had to write a simple program that calculates how many dollars, quarters, dimes, etc, from what ever the input is (in cents).
I would be so appreciative if someone could look this over for me and let me know if there is a more elegant way to do the same thing. We haven't gotten into creating functions yet but, I was thinking that a loop of some sort could do the trick but, can't think of any way to implement one.
Here's the code:
Thanks,
Pat
This is my first post to the programming section. After reading through here, I've noticed that most of you guys are less than thrilled for someone to ask for some programming help with no input of their own, so you'll be happy to see that I've completed my own very simple code.
A bit about me: I'm 28 and just returning back to school to hopefully become a computer engineer. I'm taking my very first programming class which is C++. Mind you, I have no formal programming experience, other than what I have learned since the beginning of this semester. I had to write a simple program that calculates how many dollars, quarters, dimes, etc, from what ever the input is (in cents).
I would be so appreciative if someone could look this over for me and let me know if there is a more elegant way to do the same thing. We haven't gotten into creating functions yet but, I was thinking that a loop of some sort could do the trick but, can't think of any way to implement one.
Here's the code:
Code:
#include <iostream>
using namespace std;
int main ()
{
int remainder, pennies, dollars, quarters, dimes, nickles;
cout <<"Enter the number of pennies - ";
cin >> pennies;
cout << "\n\nYou have " << pennies << " cents which is equivalent to:\n\n";
dollars = pennies / 100;
remainder = pennies % 100;
quarters = remainder / 25;
remainder = remainder % 25;
dimes = remainder / 10;
remainder = remainder % 10;
nickles = remainder / 5;
remainder = remainder % 5;
pennies = remainder;
cout << dollars << " dollar(s)\n";
cout << quarters << " quarter(s)\n";
cout << dimes << " dime(s)\n";
cout << nickles << " nickle(s), and \n";
cout << pennies << " cent(s)\n\n";
cout << "Thanks for running the change program!" << endl;
}
Thanks,
Pat