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

*New Coder* Formatting and operators

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

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

#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+";
}```