Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-26-2012, 01:58 AM   PM User | #1
SachemFB42
New to the CF scene

 
Join Date: Sep 2012
Location: New York
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
SachemFB42 is an unknown quantity at this point
Borland C++ 5.02 program issues

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
//9-25-12
//Piggy Bank

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

main()
{
double total,penny;
int weeks,dollars,nickels,dimes,quarters;
char name[20];
cout.setf(ios::fixed);

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

total=(penny)/100;

clrscr;

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";
dollars=(penny)/100;
cout<<"\t\t\t- "<<dollars<<" Dollar Bills\n";
quarters=(dollars)%25;
cout<<"\t\t\t- "<<quarters<<" Quarters\n";
dimes=(quarters)%10;
cout<<"\t\t\t- "<<dimes<<" Dimes\n";
nickels=dimes%5;
cout<<"\t\t\t- "<<nickels<<" Nickels\n";


getch();
return 0;
}
SachemFB42 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:59 PM.


Advertisement
Log in to turn off these ads.