Untitled
unknown
plain_text
2 years ago
666 B
8
Indexable
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
cout << "1 - добавить оценку" << endl << "2 - посмотреть текущий средний балл" << endl << "3 - выйти" << endl;
char s;
float average;
int marks = 0;
int quantity = 0;
int cur_mark;
do {
cin >> s;
switch (s)
{
case '1':
cout << endl << "Введите оценку: ";
cin >> cur_mark;
quantity += 1;
marks += cur_mark;
break;
case '2':
average = float(marks) / float(quantity);
cout << "Средний балл = " << average << endl;
break;
}
} while (s != '3');
}Editor is loading...