View Single Post
Old Feb 16th, 2005, 9:09 PM   #20
Xero
Hobbyist Programmer
 
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 4 Xero is on a distinguished road
Quote:
Originally Posted by breskoad
I have to write a program and i'm lost. I have to use C++ and have a program that does the following.

What's your name? Andrew

How many pennies do you have Nancy? 77

How many nickels do you have Andrew? 30

How many dimes do you have Andrew? 2

How many quarters do you have Andrew? 5

====================================================
Andrew's Net Worth
====================================================
Dollars : 3
Change : 72
====================================================

Your program should use the following values 45 pennies, 27 nickels, 15 dimes and 7 quarters.

It's for a sample class i'm taking, not necessarily homework. Any chance someone could code a program like that for me so i can see how it is done. Its a sample from my C++ book and i can't figure it out even though i've tried NUMEROUS codes. It takes your name input and then asks you how much change you have in forms of quarters, nickels, dimes, and pennies then calculates it into a dollar amount with remaining change.

Can anyone give me a hand? Possibly show me the code for it?
Umm thats such bull. If its a sample from a book, they're most likely going to have some sort of explaination. They would just put an example in a book and do nothing. So I think believe its homework, and I dont see how it could be that much trouble if you actually read the book. Its only a few simple concepts. Heres a hint... Look up "cout", "cin", "local varaiables", and "simple arthmatic"

Anyways Ill write your program for you, mainly because Im not a jerk like these other guys and Im possibly the nicest person you'll ever meet that will help you since you didn't post a sample of yours. If those are the only required inputs then this program should work flawlessly:

#include <iostream>
using namespace std;

int main ()
{
     cout << "What's your name? Andrew\n";
     cout << "How many pennies do you have Nancy? 77 \n";
     cout << "How many nickels do you have Andrew? 30 \n";
     cout << "How many dimes do you have Andrew? 2 \n";
     cout << "How many quarters do you have Andrew? 5 \n";
     cout << "======================================= \n";
     cout << "Andrew's Net Worth \n";
     cout << "======================================= \n";
     cout << "Dollars : 3 \n";
     cout << "Change : 72 \n";
     cout << "======================================= \n";

return 0;
}
__________________
...

Last edited by Xero; Feb 16th, 2005 at 9:13 PM.
Xero is offline