C ++循环/输入数据(fstream) [英] C++ Looping/Inputting data (fstream)

查看:81
本文介绍了C ++循环/输入数据(fstream)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计


我必须制作一个接受/拒绝申请进入俱乐部的计划。 该计划应阅读有关申请人的信息(没有给出,因此我认为我必须在记事本中填写一些申请人信息)并输出每个申请人的接受或拒绝声明。

每个输入行包含有关申请人的以下信息:

  • 申请人的身份证号码(0-9,999)
    年龄(0-120)

    社交技能测试分数(0-100)

    文学艺术和历史考试成绩(0- 100)

    每年收入(5,000 - 9,999,999)

    表明申请人的父母是否已经在俱乐部(y / n)


有4名法官,每位法官投票支持不同的事情:
  • 法官1票接受任何在2次测试中平均为90或更高的候选人。

    法官2票接受任何收入(数千美元)超过其年龄两倍的候选人。

    法官3票接受任何在社交技能测试中得分至少为85分的候选人谁是父母一直在俱乐部。

    法官4总是不同意法官3,除了她总是批准35岁以下的申请人并且收入更多感谢20美元0,000。


如果出现平局,评委必须进行第二次投票。在那时,如果法官2投票接受候选人,法官3将她的社交技能测试要求降低到75。如果投票仍然分开,候选人不被接受,但鼓励在3年内重新申请。


输出格式表示程序应回显输入然后输出法官投票和最终决定。在分裂决定的情况下,应打印出两组投票。如果候选人太年轻或考试不及格,则会打印出不合格的信息(不进行投票)。如果读入无效值(例如:年龄= 200或收入= 2000美元),程序应打印出错误信息并转到下一位申请人。

我的老师提到的东西关于使用记事本或excel来输入符合< fstream>的数据。标题,唯一的问题是我不知道如何。另外,当我输入我的代码时,它只是说输入候选人的ID#"


[IMG]

[/ IMG]


这是我的代码:

展开 | 选择 | 换行 | 行号

解决方案

200,000。

如果出现平局,评委必须进行第二次投票。在那时,如果法官2投票接受候选人,法官3将她的社交技能测试要求降低到75。如果投票仍然分开,候选人不被接受,但鼓励在3年内重新申请。


输出格式表示程序应回显输入然后输出法官投票和最终决定。在分裂决定的情况下,应打印出两组投票。如果候选人太年轻或考试不及格,则会打印出不合格的信息(不进行投票)。如果读入无效值(例如:年龄= 200或收入=


2000),程序应打印出错误消息并继续下一位申请人。

我的老师提到了一些关于使用记事本或excel来输入符合< fstream>的数据的内容。标题,唯一的问题是我不知道如何。另外,当我输入我的代码时,它只是说输入候选人的ID#"


[IMG]

[/ IMG]


这是我的代码:

展开 | 选择 | 换行 | 行号


< blockquote>我正在看一看;你做错了一件事就是:

展开 | 选择 | Wrap | 行号


Hey Guys

I have to make a program where it accepts/denies applications into a club. The program should read in information about applicants (None was given so I believe I have to make up some applicant info in Notepad) and output a statement of acceptance or rejection for each applicant.

Each input line contains the follwing information about the applicant:

  • Applicant''s ID number (0-9,999)
    Age (0-120)
    Score on the Test of Social Skills (0-100)
    Score on the literature Art and History test (0-100)
    Yearly Income (5,000 - 9,999,999)
    An indication of whether the applicants parents where already in the club (y/n)

There are 4 judges and each Judge vote for different things:
  • Judge 1 votes to accept any candidate who averages 90 or better on the 2 tests.
    Judge 2 votes to accept any candidate whose income, in thousands of dollars, exceeds twice his or her age.
    Judge 3 votes to accept any candidate who scores at least an 85 on the social skills test and who parents have been inthe Club.
    Judge 4 always disagrees with Judge 3 with the exception that she always approves an applicant who is under 35 years old and earns more thank $200,000.

In the event of a tie the judges have to take a second vote. At that point judge 3 lower her social skills test requirement down to 75 if Judge 2 had voted to accept the candidate. If the vote is still split, the candidate is not accepted, but is encouraged to reapply in 3 years.

The output format says that the program should echo-print the input then output the judges votes and the final decision. In the case of a split decision, both sets of votes should be printed out. If the candidate is too young or has failed the exams, a message of ineligibility is printed (no vote is taken). If an invalid value is read in (ex: age = 200 or income = $2000), the program should print out an error message and go on to the next applicant.

My teacher mentioned something about using notepad or excel to input data in compliance with an <fstream> header, only problem is I don''t know how. Plus, when I put in my code it just says "Input Candidate''s ID #"

[IMG]

[/IMG]

Here''s my code:

Expand|Select|Wrap|Line Numbers

解决方案

200,000.
In the event of a tie the judges have to take a second vote. At that point judge 3 lower her social skills test requirement down to 75 if Judge 2 had voted to accept the candidate. If the vote is still split, the candidate is not accepted, but is encouraged to reapply in 3 years.

The output format says that the program should echo-print the input then output the judges votes and the final decision. In the case of a split decision, both sets of votes should be printed out. If the candidate is too young or has failed the exams, a message of ineligibility is printed (no vote is taken). If an invalid value is read in (ex: age = 200 or income =


2000), the program should print out an error message and go on to the next applicant.

My teacher mentioned something about using notepad or excel to input data in compliance with an <fstream> header, only problem is I don''t know how. Plus, when I put in my code it just says "Input Candidate''s ID #"

[IMG]

[/IMG]

Here''s my code:

Expand|Select|Wrap|Line Numbers


I''m taking a look at it; one thing you''re doing wrong is here:

Expand|Select|Wrap|Line Numbers


这篇关于C ++循环/输入数据(fstream)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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