Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 22nd, 2005, 4:40 PM   #1
area
Newbie
 
Join Date: Nov 2005
Posts: 1
Rep Power: 0 area is on a distinguished road
need help

i've been working on this program that is suppose to use four parameters named quarters,dimes,nickels and pennies, which represent the number of quarters,dimes, pennies and nickels in a piggy bank.
i have to use a function called totamt(), to return dollar value of the number of quaters,dimes,nickels, and pennies passed to it. below is what i have, if anyone could give me a few pointers on what im doing wrong that would be great:

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

int main()
{ float t,v;
float totamt (float,float,float,float);
float total, value;
cout<<"enter a value";
cin>>value;
cout <<"the total value is"<<total<<endl;

system("PAUSE");
return 0;
}
float totamt(float q,float d,float n,float p,float t,float v)
{
if (v >= .25)
t =.25;
else if (v>=.10)
t =.10;
else if (v <=.01)
t =.01;
else if (v<=.05)
t =.05;
return totamt;

)
area is offline   Reply With Quote
Old Nov 22nd, 2005, 4:46 PM   #2
nindoja
Programmer
 
Join Date: Jun 2005
Posts: 92
Rep Power: 4 nindoja is on a distinguished road
please read the "How to post" thread, and please use [code] tags. If you do this, you increase the responses, and their helpfullness.
nindoja is offline   Reply With Quote
Old Nov 22nd, 2005, 5:49 PM   #3
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Talking

i do not think it would be fair if i told you what you did wrong and explained it to you. But here is a version of what i thought you were trying to do. Im really not sure lol!

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

float totamt(float,float,float,float);

int main()
{ 
     float total,tq,td,tn,tp;
     
     cout << "how many quarters?";
     cin >> tq;
     cout << "how many dimes?";
     cin >> td;
     cout << "how many nickels?";
     cin >> tn;
     cout << "how many pennies?";
     cin >> tp;

     total=totamt(tq,td,tn,tp);

     cout << endl << "the total value is" << total << endl;

     system("pause");
     
     return 0;
}

float totamt(float q,float d,float n,float p)
{
     float tmpTotal;

     tmpTotal+=(q*.25);
     tmpTotal+=(d*.10);
     tmpTotal+=(n*.05);
     tmpTotal+=(p*.01);
    
     return tmpTotal;
}

EDIT: i personally did not run this code...
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Nov 22nd, 2005, 5:53 PM   #4
nindoja
Programmer
 
Join Date: Jun 2005
Posts: 92
Rep Power: 4 nindoja is on a distinguished road
@Kilo: It's good you tried to help him, but you should use standard headers (iostream not iostream.h). Other than that, your code seems to work like intended.

@area: if you use kilo's code, make sure you change iostream.h to iostream, and then add the line using namespace std; after all of your includes.
nindoja is offline   Reply With Quote
Old Nov 22nd, 2005, 5:54 PM   #5
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
i just took his code and altered it... i changed nothing with his headers sorry


EDIT: and it depends on compiler also, i know MSVC++ 6.0 requires '.h'
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Nov 22nd, 2005, 6:27 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
EDIT: and it depends on compiler also, i know MSVC++ 6.0 requires '.h'
No, it doesn't.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 22nd, 2005, 7:01 PM   #7
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
yes it does.. i have used MSVC++ for 4 years you cannot include <iostream> must have '.h' there is no header directive
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Nov 22nd, 2005, 7:22 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Kilo, I have been using MSVC++ 6.0 for much longer than that. Would you like to see an example?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 22nd, 2005, 7:46 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Rather than compress this and possibly deter readability, the link is directly to my site: VC++ 6.0 Compilation. It's zoomable, if your resolution needs that.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 22nd, 2005, 7:47 PM   #10
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
all i know is that on any computer with mscv++ i have ever used typing -> #include <iostream> creates and error... period nothing i can do to change that granddaddy bro? maybe you just so happen to have a header directive? if you feel it will work send me a cpp file with it doing so... i will run it and copy paste the error?
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:43 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC