C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 18th, 2004, 10:18 PM
tomakated tomakated is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 tomakated User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink Two Errors in my functions that can't figure them out

Can anyone get the errors to go away for me, been trying for a week now. I am new to the programming world as you might tell from the format of it.
Thanks,
tomakated@comcast.net


any help that can be given that would be great< !!!.

#include <iostream>
#include <iomanip>

double findcheapest(double, double, double, double);
void printresults (double, double, double, double, double, double, double);
void instructions();
double get_item_price();
int getresponse();
char response;
int lowest;
int total;

int main()
{
double item1, item2, item3, item4, lowest=0, total;
char response;

instructions();
item1 = get_item_price();
item2 = get_item_price();
item3 = get_item_price();
item4 = get_item_price();
total = item1 + item2 + item3 + item4;
cout << "Do you have a coupon for this purchase? \n" ;
response = getresponse() ;
if (response == 'y')
{ lowest = findcheapest(item1, item2, item3, item4);
total = total - lowest;
}
printresults (response, item1, item2, item3, item4,
total, lowest);
}


double get_item_price()
{
double i;
cout << "Enter the four item prices you want to buy.";
cout << "Item1: ";
cin >> i;
while (i<0)
{
cout << "Please enter a positive number: ";
cin >> i;
}

return i;
}

int getresponse()
{
cout << "Do you have a coupon for this purchase? (y or n): .\n";
cin >> response;

if ((response == 'y') || (response == 'Y'))
{
lowest = findcheapest(double item1, double item2, double item3, double item4);
total = total - lowest;

if ((response == 'n') || (response == 'N'))
total = total;

}

double findcheapest(double item1, double item2, double item3, double item4)

{
if (((item1 <= item2) && (item1 <= item3) && (item1 <= item4)))
{
lowest = item1;
}
if (((item2 <= item1) && (item2 <= item3) && (item2 <= item4)))
{
lowest = item2;
}

if (((item3 <= item1) && (item3 <= item2) && (item3 <= item4)))
{
lowest = item3;
}

if (((item4 <= item1) && (item4 <= item2) && (item4 <= item3)))
{
lowest = item4;
}

}

void printresults(double response, double item1, double item2,
double item3, double item4, double total, double lowest)

{

cout << "Item 1 $" << setw(10) << item1 << endl;
cout << "Item 2 $" << setw(10) << item2 << endl;
cout << "Item 3 $" << setw(10) << item3 << endl;
cout << "Item 4 $" << setw(10) << item4 << endl;
cout << "Coupon Discount $(" << setw(10) << lowest<<")"<< endl;
cout << "----------------------------" << endl;
cout << "Total $" << setw(10) << total << endl;
}

"fourth.cpp" 102 lines, 2384 characters
$ g++ fourth.cpp -o fourth.out
fourth.cpp: In function `int getresponse()':
fourth.cpp:57: parse error before `,'
fourth.cpp:67: parse error before `{'
$
lowest = findcheapest(double item1, double item2, double item3, double item4); lowest = findcheapest(double item1, double item2, double item3, double item4); double findcheapest(double item1, double item2, double item3, double item4)

{

Reply With Quote
  #2  
Old November 19th, 2004, 08:05 AM
aarthy aarthy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 aarthy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi frnd,
1. The first error you have specified is "Parse Error before ," in
lowest = findcheapest(double item1, double item2, double item3, double item4);
This is where you call the function "findcheapest" .while calling the function you should not specify the data type.(here double).so after modification
lowest = findcheapest(item1, item2, item3, item4); and in the function findcheapest you have not used return statements. check that also.
2. Parse Error In fuction int getresponse() b'coz you have not closed the braces"}" . so do that.
mail me for more details.
I guess this may help you.
with Regards
aarthy.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Two Errors in my functions that can't figure them out


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT