get_item_price [英] get_item_price

查看:97
本文介绍了get_item_price的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的,我不能让我的get_item_price()函数工作我

需要它才能收到4件物品


int main()


{


double item1,item2,item3,item4,lowest = 0,total;


char响应;


说明();


item1 = get_item_price();


item2 = get_item_price();


item3 = get_item_price();


item4 = get_item_price();


total = item1 + item2 + item3 + item4;


cout<<你有这个购买的优惠券吗? \\\
" ;


response = getresponse();


if(response ==''y'')


{最低= findcheapest(item1,item2,item3,item4);


总计=总计?最低;


}


printresults(响应,第1项,第2项,第3项,第4项,总计,最低);


}


到目前为止我只有这个;

#include< iostream>

#include< iomanip>


double findcheapest(double,double,double,double);

void printresults(double,double,double,double,double ,双倍,

双倍);

int main()

{

double item1,item2,item3, item4,最低= 0,总计;

char响应;

instructions();

item1 = get_item_price();

item2 = get_item_price();

item3 = get_item_price();

item4 = get_item_price();

总计= item1 + item2 + item3 + item4;

cout<< 你有这个购买的优惠券吗? \\\
" ;

response = getresponse();

if(response ==''y'')

{最低= findcheapest(item1,item2) ,item3,

item4);

总计=总计 - 最低;

}

printresults(response,item1 ,item2,item3,item4,

总计,最低);

}

void get_item_price()

{

加倍i;

cout<< 输入您要购买的四个商品价格。\ n

cout<< Item1:";

cin>> i;

while(i< 0)

{

cout<< 请输入正数:;

cin>> i;

}


int getresponse()

{

while((response == ''y'')||(回复==''Y'')

{

cout<<"你有这个购买的优惠券吗? ?(是或否)

\ n" ;;

cin>>响应;

}

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

{

if((item1< = item2)&&(item1< = item3 )&&(item1< =

item4)))

{

最低= item1;

}

if(((item2< = item1)&&(item2< = item3)&&(item2< =

item4) ))

{

最低=第2项;

}


if((item3< ; = item1)&&(item3< = item2)&&(item3< =

item4)))

{

最低= item3;

}


if((item4< = item1)&&(item4< = item2)& ;&(item4< =

item 3)))

{

最低= item4;

}


}

void printresults(双重回复,双项1,双项2,

双项3,双项4,双项,双项最低);


{

cout<< 项目1 $ << setw(10)<< item1<< endl;

cout<< 第2项$ << setw(10)<< item2<< endl;

cout<< 第3项$ << setw(10)<< item3<< endl;

cout<< Item 4 $ << setw(10)<< item4<< endl;

cout<< 优惠券折扣$(<<<< setw(10)<<

最低<<")<<< endl;

cout<< " ----------------------------" << endl;

cout<< 总计$ << setw(10)<<总<<结束;

}


}

" fourth.cpp" 84行,2069个字符

$ g ++ fourth.cpp -o fourth.out

fourth.cpp:函数`int main()'':

fourth.cpp:13:隐式声明函数`int instructions(...)''

fourth.cpp:14:隐式声明函数`int get_item_price(...)' '

fourth.cpp:20:隐式声明函数`int getresponse(...)''

fourth.cpp:函数`void get_item_price()'' :

fourth.cpp:34:在'<''之前解析错误。

fourth.cpp:43:在'{''
$ b之前解析错误$ b fourth.cpp:47:`response''未声明(首次使用此功能)

fourth.cpp:47 :(每个未声明的标识符仅报告一次

第四.cpp:47:对于它出现的每个函数。)

fourth.cpp:顶级:

fourth.cpp:49:参数
fourth.cpp:49:参数省略了类型说明符

fourth.cpp:49:参数省略了类型说明符ter $>
fourth.cpp:在函数`double findcheapest(double)'':

fourth.cpp:51:`item2''未声明(首先使用此函数)

fourth.cpp:51:`item3''未声明(首先使用此功能)

fourth.cpp:51:`item4''未声明(首先使用此功能)

fourth.cpp:53:`最低''未申报(首先使用此功能)

fourth.cpp:顶级:

第四名。 cpp:74:解析错误之前`{''

fourth.cpp:76:语法错误之前`<''

fourth.cpp:77:语法错误之前`<''

fourth.cpp:78:在'<''之前的语法错误

fourth.cpp:79:`<''之前的语法错误br />
fourth.cpp:80:在'<''之前的语法错误

fourth.cpp:81:在'<''
$ b $之前的语法错误b我无法弄清楚要做什么< !!!。

任何人都可以帮忙吗?<。

解决方案
" << setw(10)<< item1<< endl;

cout<< 项目2


" << setw(10)<< item2<< endl;

cout<< 项目3


" << setw(10)<< item3<< endl;

cout<< 第4项


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<?.

解决方案

" << setw(10) << item1 << endl;
cout << "Item 2


" << setw(10) << item2 << endl;
cout << "Item 3


" << setw(10) << item3 << endl;
cout << "Item 4


这篇关于get_item_price的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆