T
tomakated
Hi, i'm new here and I can't get my get_item_price() function to work I
need it to take in 4 items
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);
}
and so far all I have is this;
#include <iostream>
#include <iomanip>
double findcheapest(double, double, double, double);
void printresults (double, double, double, double, double, double,
double);
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);
}
void get_item_price()
{
double i;
cout << "Enter the four item prices you want to buy.\n"
cout << "Item1: ";
cin >> i;
while (i<0)
{
cout << "Please enter a positive number: ";
cin >> i;
}
int getresponse()
{
while ((response == 'y' ) || (response == 'Y')
{
cout << "Do you have a coupon for this pruchase? (y or n)
\n";
cin >> response;
}
double findcheapest(double item1, item2, item3, 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" 84 lines, 2069 characters
$ g++ fourth.cpp -o fourth.out
fourth.cpp: In function `int main()':
fourth.cpp:13: implicit declaration of function `int instructions(...)'
fourth.cpp:14: implicit declaration of function `int get_item_price(...)'
fourth.cpp:20: implicit declaration of function `int getresponse(...)'
fourth.cpp: In function `void get_item_price()':
fourth.cpp:34: parse error before `<'
fourth.cpp:43: parse error before `{'
fourth.cpp:47: `response' undeclared (first use this function)
fourth.cpp:47: (Each undeclared identifier is reported only once
fourth.cpp:47: for each function it appears in.)
fourth.cpp: At top level:
fourth.cpp:49: type specifier omitted for parameter
fourth.cpp:49: type specifier omitted for parameter
fourth.cpp:49: type specifier omitted for parameter
fourth.cpp: In function `double findcheapest(double)':
fourth.cpp:51: `item2' undeclared (first use this function)
fourth.cpp:51: `item3' undeclared (first use this function)
fourth.cpp:51: `item4' undeclared (first use this function)
fourth.cpp:53: `lowest' undeclared (first use this function)
fourth.cpp: At top level:
fourth.cpp:74: parse error before `{'
fourth.cpp:76: syntax error before `<'
fourth.cpp:77: syntax error before `<'
fourth.cpp:78: syntax error before `<'
fourth.cpp:79: syntax error before `<'
fourth.cpp:80: syntax error before `<'
fourth.cpp:81: syntax error before `<'
and I can't figure out what to do<!!!.
Can anyone help out<?.
need it to take in 4 items
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);
}
and so far all I have is this;
#include <iostream>
#include <iomanip>
double findcheapest(double, double, double, double);
void printresults (double, double, double, double, double, double,
double);
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);
}
void get_item_price()
{
double i;
cout << "Enter the four item prices you want to buy.\n"
cout << "Item1: ";
cin >> i;
while (i<0)
{
cout << "Please enter a positive number: ";
cin >> i;
}
int getresponse()
{
while ((response == 'y' ) || (response == 'Y')
{
cout << "Do you have a coupon for this pruchase? (y or n)
\n";
cin >> response;
}
double findcheapest(double item1, item2, item3, 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" 84 lines, 2069 characters
$ g++ fourth.cpp -o fourth.out
fourth.cpp: In function `int main()':
fourth.cpp:13: implicit declaration of function `int instructions(...)'
fourth.cpp:14: implicit declaration of function `int get_item_price(...)'
fourth.cpp:20: implicit declaration of function `int getresponse(...)'
fourth.cpp: In function `void get_item_price()':
fourth.cpp:34: parse error before `<'
fourth.cpp:43: parse error before `{'
fourth.cpp:47: `response' undeclared (first use this function)
fourth.cpp:47: (Each undeclared identifier is reported only once
fourth.cpp:47: for each function it appears in.)
fourth.cpp: At top level:
fourth.cpp:49: type specifier omitted for parameter
fourth.cpp:49: type specifier omitted for parameter
fourth.cpp:49: type specifier omitted for parameter
fourth.cpp: In function `double findcheapest(double)':
fourth.cpp:51: `item2' undeclared (first use this function)
fourth.cpp:51: `item3' undeclared (first use this function)
fourth.cpp:51: `item4' undeclared (first use this function)
fourth.cpp:53: `lowest' undeclared (first use this function)
fourth.cpp: At top level:
fourth.cpp:74: parse error before `{'
fourth.cpp:76: syntax error before `<'
fourth.cpp:77: syntax error before `<'
fourth.cpp:78: syntax error before `<'
fourth.cpp:79: syntax error before `<'
fourth.cpp:80: syntax error before `<'
fourth.cpp:81: syntax error before `<'
and I can't figure out what to do<!!!.
Can anyone help out<?.