100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS1512 Assignment 3 2024 solution ready to submit R115,33
Add to cart

Other

COS1512 Assignment 3 2024 solution ready to submit

 19 views  0 purchase

COS1512 Assignment 3 2024 solution Answer all the questions. Submit all the programs you are required to write, as well as the input and output of all programs. Copy the programs and the required input and output to ONE word processor file with single line spacing and convert it to a PDF file b...

[Show more]

Preview 4 out of 14  pages

  • August 11, 2024
  • 14
  • 2024/2025
  • Other
  • Unknown
All documents for this subject (45)
avatar-seller
CrystalIndigo
COS1512 2024 ASSIGNMENT 3
Ready to submit
(with the source code you need)

Crystal Indigo!
Crystal Indigo!
Providing all solutions you need anytime
+27 76 626 8187




***copy and run the code, then submit what you need to submit***
if there is a program that is not running, please contact

,Output
Q1




Q4




Q5



Q6

,Q7




Question 1
#include <iostream>
#include <string>

using namespace std;

class Student
{
private:
string name;
int quiz1;
int quiz2;
int midtermExam;
int finalExam;

public:
// Default constructor
Student() : name(""), quiz1(0), quiz2(0), midtermExam(0), finalExam(0) {}

// Mutators (setters)
void setName(string n) { name = n; }
void setQuiz1(int q1) { quiz1 = q1; }
void setQuiz2(int q2) { quiz2 = q2; }
void setMidtermExam(int me) { midtermExam = me; }

, void setFinalExam(int fe) { finalExam = fe; }

// Accessors (getters)
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; }

// Calculate weighted average
int calculateAverage() const
{
int quizAverage = (quiz1 + quiz2) / 2.0; // average of quizzes
quizAverage = (quizAverage / 10.0) * 25; // convert to percentage and
weight
int midtermScore = (midtermExam / 100.0) * 25;
int finalScore = (finalExam / 100.0) * 50;
return quizAverage + midtermScore + finalScore;
}
};

int main()
{
Student student;

// Input student data
cout << "Student name: ";
string name;
getline(cin, name);
student.setName(name);

int quiz1, quiz2, midterm, finalExam;
cout << "Quiz 1: ";
cin >> quiz1;
cout << "Quiz 2: ";
cin >> quiz2;
cout << "Midterm exam: ";
cin >> midterm;
cout << "Final exam: ";
cin >> finalExam;

student.setQuiz1(quiz1);
student.setQuiz2(quiz2);
student.setMidtermExam(midterm);
student.setFinalExam(finalExam);

// Output student record
cout << "\nStudent Record:\n";
cout << "Name: " << student.getName() << "\n";
cout << "Quiz 1: " << student.getQuiz1() << "\n";
cout << "Quiz 2: " << student.getQuiz2() << "\n";
cout << "Midterm Exam: " << student.getMidtermExam() << "\n";
cout << "Final Exam: " << student.getFinalExam() << "\n";
cout << "Weighted Average: " << student.calculateAverage() << "\n";

return 0;
}

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller CrystalIndigo. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R115,33. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

53022 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R115,33
  • (0)
Add to cart
Added