关于硬件伪代码的问题
我有以下问题,我最困惑的是如何执行逻辑来确定支票是否晚了一个月。
问题是:
“为一个程序编写伪代码,计算客户因开出空头支票而欠下的服务费。该程序接受客户的姓名、支票签发日期(年、月和日)、当前日期(年) 、月和日),以及支票金额(以美元和美分计) 该程序将继续,直到遇到 eof 值。服务费为 20 美元加上支票金额的 2%,每个月加收 5 美元。因为新的一个月一开始,支票就晚了一个月,所以 9 月 30 日写的空头支票就比 10 月 1 日晚了一个月。”
到目前为止,我现在写的是:
Start
string Name
num AmountOwed
num DateCheckWritten
num CurrentDate
num CheckAmount
get Name, DateCheckWritten, CurrentDate, CheckAmount
while eof
I have the following question, and what I'm most confused on, is how to do the logic for determining if a check is one month late or not.
Question is:
"Write pseudocode for a program that calculates the service charge of a customer owes for writing a bad check. The program accepts a customer's name, the date the check was written (year, month and day), the current date (year, month and day), and the amount of the check in dollars and cents. The program continues until an eof value is encountered. The service charge is $20 plus 2 percent of the amount of the check, plus $5 for every month that has passed since the check was written. A check is one month late as soon as a new month starts-so a bad check written on September 30 is one month overdue on October 1."
So far what I have write now is:
Start
string Name
num AmountOwed
num DateCheckWritten
num CurrentDate
num CheckAmount
get Name, DateCheckWritten, CurrentDate, CheckAmount
while eof
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于您不必处理几天的问题,因此算法非常简单:
祝剩下的问题好运!
Since you don't have to deal with days, the algorithm is very straightforward:
Good luck with the rest of the problem!
我不确定你的问题出在哪里,但我认为你有两个问题需要处理:
因此,在我的伪代码中,我将有一个步骤确定支票晚到的时间,然后再执行另一个步骤来计算费用。在第一步中,您只需减去天数并除以即可。但指示说,一旦新的一个月到来,就晚了一个月。所以你真正要做的就是减去几个月。
不确定您还想问什么,但看来您是在寻求指导,而不是代码。希望这有帮助。
I'm not sure where your problem lies, but I think you have two issues to deal with:
So in my pseudocode, I would have a step that determines how late a check is, and then another step to calculate the fee. Inside the first step, you could just subtract the days and divide. But the directions say as soon as a new month comes along, it is one month late. So all you really have to do is subtract months.
Not sure what else you are asking, but it appears you are asking for guidance, not code. Hope this helps.
我假设这是家庭作业,因此我会尽力为您指出正确的方向。
如果您为每个月分配数字(一月 = 1,二月 = 2 等),那么两个日期之间的月份数很容易确定 - 九月 (= 9) 和五月 (= 5) 之间有多少个月?
另一件需要考虑的事情是年份 - 对于支票逾期的每一年,您还必须另外添加十二个月。这与几个月的工作原理相同。
需要任何额外的细节,请随时告诉我。
I'm going to assume this is homework, and as such I'll try to just point you in the right direction.
If you assign numbers to each month (Jan = 1, Feb = 2, etc) then the number of months between two dates is easy to determine - how many months are there between September (= 9) and May (= 5)?
The other thing to take into account is the year - for each year the check is late, you'll also have to add another twelve months. This works the same as for months.
Need any extra detail, feel free to let me know.
简化,抓住要点,然后越来越多地分解,按照你会告诉你的奶奶它有效的方式写下来。
你可能会从类似的事情开始
Simplify, hit the main points and then break it down more and more, write it how you would tell your grandma it worked.
you might start out with something like