*新的编码器*格式和运算符

*New Coder* Formatting and operators

本文关键字:运算符 格式 编码器      更新时间:2023-10-16

嗨,我刚开始学习C++,我有一个提示程序:

  • 它类似于要求用户一次输入一个作业,一旦他们没有更多的输入,程序必须显示"Stop"

  • 它必须询问用户是否在每个分数(布尔类型(中输入更多分数

  • 它还必须获得平均值并将其置于 100 的范围内并输出相关的分数,量表为:A = 100-93A- = 92-90B+ = 89-87

以下是我到目前为止所拥有的(如果我可以为编译器更好地格式化它,请告诉我,我更喜欢在记事本中输入(

#include <iostream>
using namespace std;
int main() {
cout << "Welcome to the Homework Point Sum Progam!"
endl;
cout << "How many assignments did you complete?:";
endl;
int assignments;
int scores;
int total = 0;
int average = scores / assignents;
cin >> assignments;
// this next part I'm trying to find out how to set up the input for the assignments and have them line up as "assignment one, assignment two, etc."
if (assignment > 0) {
for (int i = 1; i < assignment; i++) {
else
// I would like to know if this is a valid input and formatting of "else" as well as if my placement of it is valid
cout << "Enter Assignment Score" << i << endl;
cin >> scores
total += scores
}
}
if (average < 33)
total += scores
cout << "Fail" << endl:
return 0;
}

继续在最后几行添加其他成绩,使用 else if(您的条件(。如果你想让我补充什么,请告诉我。

using namespace std;
int main(){
cout<<"Welcome to the Homework Point Sum Progam!" <<endl;
cout<<"How many assignments did you complete?:"<< endl;
int numberOfAsssignement=0;
int total =0;
float average =0;
cin >> numberOfAsssignement;
cout << "Please enter your assignements results:";
int assignements[numberOfAsssignement-1];
for(int i=0; i < numberOfAsssignement; i++){
cin >>assignements[i];
}
for(int i=0; i < numberOfAsssignement; i++){
total +=assignements[i];
}
average = (total/numberOfAsssignement)*10;
cout << average;
if(average>=93) cout << "A";
else if(average<93 && average >=90) cout << "A-";
else if(average<90 && average >=87) cout << "B+";
}```