#include <iostream>
#include <string>
#include <sstream>
#include <unistd.h>
using namespace std;
int main()
{
int score;
string name, sco;
cout<<"Hello! I am Mrs. Marian! I am the administratress of this humble website!"<<'\n';
cout<<"This website is kindly brought to you by our Prime Minister Candry Veneroth."<<'\n';
cout<<"This is the 'National School Grading System', or the NSGS, to help you see if your student fails or not."<<'\n';
cout<<"The first thing you have to do is type the student's name: "<<'\n';
getline(cin,name);
cout<<"Great! Now please enter "<<name<<"'s correct answers in the National Education Test: ";
getline(cin,sco);
stringstream(sco)>>score;
cout<<"The NET (National Education Test) has a total score of 180 with 150 questions with each question having a score of 1.2"<<'\n';
cout<<"Loading data"<<'\n';
if (score*1.2<90, score*1.2>=0)
{
cout<<"The student "<<name<<" has NOT PASSED, with a score of "<<score*1.2<<". I am sorry, and hope the best for next time.";
}
else if (score*1.2<180, score*1.2>=90)
{
cout<<"CONGRATULATIONS!"<<'\n'<<"The student "<<name<<" has PASSED, with a score of "<<score*1.2<<". Once again, congratulations!";
}
else if (score*1.2==180)
{
cout<<"CONGRATULATIONS!!!"<<'\n'<<"The student "<<name<<" has PASSED with a perfect score of "<<score*1.2<<". You will have a bright future ahead of you, "<<name<<". And I hope you for a bright future";
}
else if (score*1.2>180, score*1.2<0)
{
cout<<"This is invalid, and entering an invalid score in the NSGS is considered an act of malice against the students of Lantreind and is illegal according to the National Education Test Act (NETA) verse 5:";
cout<<'\n'<<"'For thee who dare to destroy a student's scores, shall be convicted in the name of the Veneroth name.'"<<'\n'<<"You have been warned.";
}
}
よし、イイ!私は初心者です!「if else」関数の練習..次のようにできるようになりたい:
- スコアが 0 ~ 89 の場合、合格しません。
- スコアが 90 ~ 179 の場合、合格となります。
- 180点あれば満点で合格!わーい!
- スコアが 0 未満または 180 を超える場合は、正しく行うようにプログラムに指示するようにしました。
コードをいじっていて、最初は1番目と2番目の「ifとif else(s)」に「カンマの後のコード」がありません。したがって、スコアが 180 または -897 または 1131 であっても、3 番目と 4 番目の「if else(s)」を完全に無視して、(合格/不合格) と表示されます。
おー!また、 # include を入れた理由が明らかなように「一時停止(1)」したいのですが、うまくいきません!メッセージは =
エラー: 関数 'int pause ()' への引数が多すぎます
これを修正する方法が本当にわかりません。何が間違っているのか、修正する方法を誰かが見つけて、本来の方法で実行できるようにしてくれることを願っています..
ありがとうございました!
敬具、クランチガム