Question
C++ program 1. What can I write for my code instead of setprecision (1)? string Subject::toString() { stringstream stream; // Formatting note with a digie
C++ program
1. What can I write for my code instead of "setprecision (1)"?
string Subject::toString() { stringstream stream; // Formatting note with a digie after point stream << fixed << setprecision(1) << grade; return description + ":" + stream.str(); }
2. Can I replace the for and if with another option?
void Student::sortByGrade() { // Verwenden der Auswahlsortierung, um die Fcher nach Klassen zu sortieren for (int i = 0; i < SUBJECT_ - 1; i++) { int index = -1; // Standardmaximalwert double lowGrade = 10.0; // Suche nach dem Miniumum-Element for (int j = i; j < SUBJECT_; j++) { if (subjects[i].getGrade() < lowGrade) { lowGrade = subjects[i].getGrade(); index = i; } } // tausche es bei Bedarf mit i'th aus if (index != i) { Subject sw = subjects[i]; subjects[i] = subjects[index]; subjects[index] = sw; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started