COS1512 ASSIGNMENT 03
Friday, 23 August 2024, 12:00 PM
Year Module 2024
PASS WITH DISTINCTIONS. FORTIS PASSUM
FOR FURTHER ASSISTANCE WITH ECONOMICS,
MANAGEMENT, ACCOUNTING, TAXATION EDUCATION@ LLB
MODULES.
CALL/WHATSAAP0816884518/0816884519
EMAIL:
,Question 1
#include <iostream>
#include <string>
class Student {
private:
std::string name;
int quiz1;
int quiz2;
int midtermExam;
int finalExam;
public:
// Default constructor
Student() : name(""), quiz1(0), quiz2(0), midtermExam(0), finalExam(0) {}
// Mutators
void setName(const std::string& studentName) {
name = studentName;
}
void setQuiz1(int score) {
quiz1 = score;
}
void setQuiz2(int score) {
quiz2 = score;
}
,void setMidtermExam(int score) {
midtermExam = score;
}
void setFinalExam(int score) {
finalExam = score;
}
// Accessors
std::string getName() const {
return name;
}
int getQuiz1() const {
return quiz1;
}
int getQuiz2() const {
return quiz2;
}
int getMidtermExam() const {
return midtermExam;
}
int getFinalExam() const {
return finalExam;
}
, // Function to calculate the weighted average score
double calculateAverage() const {
double quizPercentage = (static_cast<double>(quiz1) / 10 +
static_cast<double>(quiz2) / 10) / 2 * 100;
double average = (quizPercentage * 0.25) + (midtermExam * 0.25) + (finalExam *
0.50);
return average;
}
};
int main() {
Student student;
// Input the student data
std::string name;
int quiz1, quiz2, midtermExam, finalExam;
std::cout << "Student name: ";
std::getline(std::cin, name);
student.setName(name);
std::cout << "Quiz 1: ";
std::cin >> quiz1;
student.setQuiz1(quiz1);
Friday, 23 August 2024, 12:00 PM
Year Module 2024
PASS WITH DISTINCTIONS. FORTIS PASSUM
FOR FURTHER ASSISTANCE WITH ECONOMICS,
MANAGEMENT, ACCOUNTING, TAXATION EDUCATION@ LLB
MODULES.
CALL/WHATSAAP0816884518/0816884519
EMAIL:
,Question 1
#include <iostream>
#include <string>
class Student {
private:
std::string name;
int quiz1;
int quiz2;
int midtermExam;
int finalExam;
public:
// Default constructor
Student() : name(""), quiz1(0), quiz2(0), midtermExam(0), finalExam(0) {}
// Mutators
void setName(const std::string& studentName) {
name = studentName;
}
void setQuiz1(int score) {
quiz1 = score;
}
void setQuiz2(int score) {
quiz2 = score;
}
,void setMidtermExam(int score) {
midtermExam = score;
}
void setFinalExam(int score) {
finalExam = score;
}
// Accessors
std::string getName() const {
return name;
}
int getQuiz1() const {
return quiz1;
}
int getQuiz2() const {
return quiz2;
}
int getMidtermExam() const {
return midtermExam;
}
int getFinalExam() const {
return finalExam;
}
, // Function to calculate the weighted average score
double calculateAverage() const {
double quizPercentage = (static_cast<double>(quiz1) / 10 +
static_cast<double>(quiz2) / 10) / 2 * 100;
double average = (quizPercentage * 0.25) + (midtermExam * 0.25) + (finalExam *
0.50);
return average;
}
};
int main() {
Student student;
// Input the student data
std::string name;
int quiz1, quiz2, midtermExam, finalExam;
std::cout << "Student name: ";
std::getline(std::cin, name);
student.setName(name);
std::cout << "Quiz 1: ";
std::cin >> quiz1;
student.setQuiz1(quiz1);