Answer the question
In order to leave comments, you need to log in
How to fix a bug with entering data into a class?
I have a program that needs to enter data about a student and output it through a class. I made the output and the input too, but when compiling, it displays an error. How to fix ?
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
class Student {
string surname;
string name;
string patronymic;
public:
int informatics;
int algorithmization;
int algorithm;
float sum() {
return float(informatics+algorithmization+algorithm)/3;
}
void vvod() {
cout << "Введите Фамилию студента: ";
cin >> surname;
cout << "\nВведите Имя студента: ";
cin >> name;
cout << "\nВведите Отчество студента: ";
cin >> patronymic;
cout << "\nВведите оценку по информатике: ";
cin >> informatics;
cout << "\nВведите оценку по алгоритмизации: ";
cin >> algorithmization;
cout << "\nВведите оценка по теории алгоритмам: ";
cin >> algorithm;
}
float max() {
if (informatics > algorithmization && informatics > algorithm) {
return informatics;
}
if (algorithmization > informatics && algorithmization > algorithm) {
return algorithmization;
}
if (algorithm > algorithmization && algorithm > informatics) {
return algorithm;
}
return algorithm;
}
void maxSpisok() {
if (informatics >= algorithmization && informatics >= algorithm) {
cout << "\n По информатике";
}
if (algorithmization >= informatics && algorithmization >= algorithm) {
cout << "\n По алгоритмизации";
}
if (algorithm >= algorithmization && algorithm >= informatics) {
cout << "\n По теории алгоритмов";
}
}
void spisok() {
bool p = false;
if (informatics < max()) {
cout << "\nОценка по информатики ниже средней: " << informatics;
p = true;
};
if (algorithmization < max()) {
cout << "\nОценка по алгоритмизации ниже средней: " << algorithmization;
p = true;
};
if (algorithm < max()) {
cout << "\nОценка по теории алгоритмов ниже средней: " << algorithm;
p = true;
};
if (p == false) {
cout << "\n\tОценок ниже средней нету!";
};
}
float vyvod() {
cout << "Информация о студенте";
cout << "\nФамилия: " << surname;
cout << "\nИмя: " << name;
cout << "\nОтчество: " << patronymic;
cout << "\nОценка по информатике: " << informatics;
cout << "\nОценка по алгоритмизации: " << algorithmization;
cout << "\nОценка по теории алгоритмов: " << algorithm;
cout << fixed;
cout.precision(2);
cout << "\nСредний бал всех оценок: " << sum();
cout << fixed;
cout.precision(0);
return 0;
};
Student(string surname_n, string name_n, string patronymic_n, int informatics_n, int algorithmization_n, int algorithm_n) {
surname = surname_n;
name = name_n;
patronymic = patronymic_n;
informatics = informatics_n;
algorithmization = algorithmization_n;
algorithm = algorithm_n;
};
Student() {};
~Student() {};
string getSurname() {return surname;}
string getName() {return name;}
string getPatronymic() {return patronymic;}
void setSurname(string surname_n) { surname = surname_n; }
void setName(string name_n) { name = name_n; }
void setPatronymic(string patronymic_n) { patronymic = patronymic_n; }
};
//s1("Корегин", "Александр", "Алексеевич",5,3,2);
int main() {
Student s1();
s1.vvod();
s1.vyvod();
cout << "\nОценки ниже средней: ";
s1.spisok();
cout << "\nНаибольшая оценка: " << s1.max();
s1.maxSpisok();
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question