c ++帮助....我被困在中间...... [英] c++ help....i'm stuck in the middle...

查看:50
本文介绍了c ++帮助....我被困在中间......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮我解决以下C ++问题:


编写程序以帮助本地书店自动化其结算系统。

该程序应执行以下操作:


(a)让用户输入ISBN,系统会自动跟踪书名和

的价格。系统应该检查

书是否在库存中。如果不是,请让用户再次输入



(b)允许顾客从书店购买多件商品。

(c)计算并打印账单。结算金额应包含5%

税。


样本输出:


欢迎来到Billy''BookShop


请输入ISBN:0128

标题为C ++如何编程

价格为RM 108.90


你想继续吗?是/否
$ b $


请输入ISBN:0992

标题是Java编程简介

价格是RM 89.60


你想继续吗? y / n

n


您的收据:


0128 RM 108.90

0992 RM 89.60

总计RM 198.50

税金RM 9.92


总计RM 208.42


谢谢!!!


p / s:我要感谢谁解决了这个问题..我很感谢你的帮助......


下面...我做了一些编码...没完成

希望有些人能帮我完成


源代码< not Complete>


#include< iostream.h>

#include< stdlib.h>


struct bookshop

{

int ISDN;

char title;

int price;

} book [];


void printbook(书店书);


int main()


{

浮动金额,费率;

int year;

cout<<"请输入金额:" ;;

cin>>金额;

cout<<"请输入投资年数:" ;;

cin>>年;

cout<<"请输入每年的利率:" ;;

cin>>率;


for(int y = 0; y< year; y ++)

amount = amount +(amount * rate / 100);


cout<<"你拥有的金额<<< year<< 年份是:

<<金额<< endl;


返回0;

}

解决方案

* JT:

帮我解决以下C ++问题:

编写程序以帮助本地书店自动化其计费系统。
程序应该做到以下几点:

(a)让用户输入ISBN,系统会自动追踪书的标题和价格。系统应检查
书是否在库存中。如果不是,请让用户再次进入

(b)允许顾客从书店购买多件物品。
(c)计算并打印账单。账单金额应包括5%税。


做我的作业在这个小组中是偏离主题的。


#include< iostream.h>


非标准标题。


#include< stdlib.h>

struct bookshop


误导名称;使用自描述名称。


{
int ISDN;


不要使用除宏之外的所有大写名称。


char title;
int price;
}书[];


数组必须有大小。


无论如何,使用std :: vector而不是原始数组。

并且不要使用全局。

void printbook(书店书);


传递价值可能不是一个好主意。


int main()

{
浮动金额,费率;
年份;
cout<<"请输入金额:" ;;
cin>>金额;
cout<<"请输入投资年数:" ;;
cin>>年;
cout<<"请输入每年的利率:" ;;
cin>>对于(int y = 0; y< year; y ++)
amount = amount +(amount * rate / 100);

cout< <"您拥有的金额<<< year<< 年份是:
<<金额<< endl;

返回0;
}




此代码与问题完全无关。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕东西?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?


JT写道:

帮我解决以下C ++问题:

编写一个程序来帮助本地书店自动化其计费系统。
程序应该做到以下几点:

(a)让用户输入ISBN,系统会自动追踪书的标题和价格。系统应检查
书是否在库存中。如果不是,请让用户再次进入

(b)允许顾客从书店购买多件物品。
(c)计算并打印账单。计费金额应包含5%的税金。

样品输出:

欢迎来到Billy''BookShop

请输入ISBN :0128
标题是C ++如何编程
价格是RM 108.90

你想继续吗? y / n

请输入ISBN:0992
标题是Java编程简介
价格是RM 89.60

你想继续吗?你的收据:

0128 RM 108.90
0992 RM 89.60
总RM 198.50
Tax RM 9.92

总RM 208.42

谢谢!

p / s:我要感谢谁解决了这个问题..我很感激你帮助..

下面......我做了一些编码......没完成
希望有些人能帮我完成

源代码< not Complete>

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

struct bookshop
{
int ISDN;
char title;
int price;
} book [];

void printbook(书店书);




我真的会说你一开始就被困住了。大概这个

是你必须编写的第一个实质性程序。


最重要的建议是不要尝试将程序全部编写在一起/>
go。选择哪一个你认为最容易的部分,做到这一点

它的工作,然后进入下一部分。


例如,在你之上写了


void printbook(书店书);


为什么不写printbook功能呢?忘掉剩下的

问题,编写printbook函数,编写几本书来打印
,看看函数是否有效。继续这样做,直到它确定

然后转到问题的下一部分。像这样的东西


struct Book

{

int ISBN;

...

};


预订a_book = {1234,用C ++编程,...};

Book another_book = {5678,Programming in Java,...};


void printbook(Bookbook);


int main( )

{

printbook(a_book);

printbook(another_book);

返回0;

}


void printbook(Bookbook)

{

...

}


你填写我写的部分...


这是最重要的建议,请在小步骤,让每个

步骤工作,然后再进入下一个。


john


John Harrison写道:

void printbook(Bookbook);

int main()
{printbook(a_book);
printbook( another_book);
返回n 0;
}

void printbook(Bookbook)
{
...
}


我确定上面的错误是拼写错误或posto,而不是thinko,但是对于

,为了OP,在上面,

void printbook( Bookbook);


应该是

void printbook(Book book);




Gregg


Help me the following C++ question:

Write a program to help a local bookshop automate its billing system.
The program should do the following:

(a)Let the user enter the ISBN, the system will trace the title and
price of the book automatically. The system should check whether the
book is in the stock or not. If it is not, please let the user to enter
again.
(b)Allow a customer to buy more than one item from the bookshop.
(c)Calculate and print the bill. The billing amount should include 5%
tax.

Sample Output:

Welcome to Billy''BookShop

Please enter the ISBN: 0128
The title is C++ How to Program
The Price is RM 108.90

Do you wish to continue? y/n
y

Please enter the ISBN: 0992
The title is Introduction to Java Programming
The Price is RM 89.60

Do you wish to continue? y/n
n

Your Receipt:

0128 RM 108.90
0992 RM 89.60
Total RM 198.50
Tax RM 9.92

Total RM 208.42

THANK YOU!!!

p/s: I would thanks for who solve this problems..i appreciate ur help..

Below...r some coding i hv done..not completed
hope some 1 will help me complete

Source Code<not Complete>

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

struct bookshop
{
int ISDN;
char title;
int price;
}book[];

void printbook (bookshop book);

int main()

{
float amount, rate;
int year;
cout <<"Please enter the amount: ";
cin >> amount;
cout <<"Please enter the number of years to invest: ";
cin >> year;
cout <<"Please enter the interest rate per year: ";
cin >> rate;

for (int y=0;y<year;y++)
amount = amount + (amount*rate/100);

cout <<"The amount you have "<<year<< "year is:"
<< amount<<endl;

return 0;
}

解决方案

* JT:

Help me the following C++ question:

Write a program to help a local bookshop automate its billing system.
The program should do the following:

(a)Let the user enter the ISBN, the system will trace the title and
price of the book automatically. The system should check whether the
book is in the stock or not. If it is not, please let the user to enter
again.
(b)Allow a customer to buy more than one item from the bookshop.
(c)Calculate and print the bill. The billing amount should include 5%
tax.
"Do my homework" is off-topic in this group.

#include <iostream.h>
Non-standard header.

#include<stdlib.h>

struct bookshop
Misleading name; use self-describing names.

{
int ISDN;
Don''t use all uppercase names except for macros.

char title;
int price;
}book[];
Arrays must have sizes.

Anyway, use a std::vector instead of a raw array.

And don''t use globals.
void printbook (bookshop book);
Probably not a good idea to pass by value.

int main()

{
float amount, rate;
int year;
cout <<"Please enter the amount: ";
cin >> amount;
cout <<"Please enter the number of years to invest: ";
cin >> year;
cout <<"Please enter the interest rate per year: ";
cin >> rate;

for (int y=0;y<year;y++)
amount = amount + (amount*rate/100);

cout <<"The amount you have "<<year<< "year is:"
<< amount<<endl;

return 0;
}



This code is totally unrelated to the problem.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


JT wrote:

Help me the following C++ question:

Write a program to help a local bookshop automate its billing system.
The program should do the following:

(a)Let the user enter the ISBN, the system will trace the title and
price of the book automatically. The system should check whether the
book is in the stock or not. If it is not, please let the user to enter
again.
(b)Allow a customer to buy more than one item from the bookshop.
(c)Calculate and print the bill. The billing amount should include 5%
tax.

Sample Output:

Welcome to Billy''BookShop

Please enter the ISBN: 0128
The title is C++ How to Program
The Price is RM 108.90

Do you wish to continue? y/n
y

Please enter the ISBN: 0992
The title is Introduction to Java Programming
The Price is RM 89.60

Do you wish to continue? y/n
n

Your Receipt:

0128 RM 108.90
0992 RM 89.60
Total RM 198.50
Tax RM 9.92

Total RM 208.42

THANK YOU!!!

p/s: I would thanks for who solve this problems..i appreciate ur help..

Below...r some coding i hv done..not completed
hope some 1 will help me complete

Source Code<not Complete>

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

struct bookshop
{
int ISDN;
char title;
int price;
}book[];

void printbook (bookshop book);



Well really I would say you are stuck at the beginning. Presumably this
is the first substantial program you have had to write.

The most important advice is not to try and write the program all in one
go. Pick which every you think is the easiest part first, do that an get
it working, then go onto the next part.

For instance, above you have written

void printbook (bookshop book);

well why not write the printbook function? Forget about the rest of the
problem, write the printbook function, make up a couple of books to
print, and see if the function works. Keep going at that until it does
and then move onto the next part of the problem. Something like this

struct Book
{
int ISBN;
...
};

Book a_book = { 1234, "Programming in C++", ... };
Book another_book = { 5678, "Programming in Java", ... };

void printbook(Bookbook);

int main()
{
printbook(a_book);
printbook(another_book);
return 0;
}

void printbook(Bookbook)
{
...
}

You fill in the parts where I''ve written ...

This is the most important advice, do this in small steps and get each
step working before you move onto the next.

john


John Harrison wrote:

void printbook(Bookbook);

int main()
{
printbook(a_book);
printbook(another_book);
return 0;
}

void printbook(Bookbook)
{
...
}

I''m sure the error above was a typo or posto, and not a thinko, but for
the sake of the OP, in the above,
void printbook(Bookbook);
should be
void printbook(Book book);



Gregg


这篇关于c ++帮助....我被困在中间......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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