View Full Version : Borland C++ 5.02 program issues

09-26-2012, 02:58 AM
I"m new to programming in C++, in fact I'm new to programming in total. I'm working on a project for school where I have to write a program that will act sort of as a piggy bank. The idea of the program is that it will ask for your name, how many weeks you have been saving up for, and how many pennies you have saved in total. It will then tel you many dollar bills, nickels, dimes, and quarters you can exchange it for.
The name doesn't matter what you put it in as, but I've been using 4 weeks as a baseline, with a total of 590 pennies saved up. It should tell me I could exchange it for 5 dollar bills, 3 quarters, 1 dime, and 1 nickel, however, when I put the 590 pennies in and the 4 weeks, it tells me I have saved $5.90 in 4 weeks, and I can exchange it for 5 dollar bills, 5 quarters, 5 dimes, and 0 nickels.
Here is a copy of my program: Note that it is in Borland C++ version 5.02 (1997)

//Justin Rooney
//Piggy Bank

#include <iostream.h>
#include <conio.h>
#include <iomanip.h>

double total,penny;
int weeks,dollars,nickels,dimes,quarters;
char name[20];

cout<<"What is your name? ";
cout<<"How many weeks have you been saving up for? ";
cout<<"How many pennies have you save up? ";



cout<<"\n\nHi "<<name<<", you have saved up $"<<setprecision(2)<<total<<" in "<<weeks<<" weeks\n";
cout<<"\nYou can exchange this for the following:\n\n";
cout<<"\t\t\t- "<<dollars<<" Dollar Bills\n";
cout<<"\t\t\t- "<<quarters<<" Quarters\n";
cout<<"\t\t\t- "<<dimes<<" Dimes\n";
cout<<"\t\t\t- "<<nickels<<" Nickels\n";

return 0;

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum