Assignment 2
Assignment 2
1
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
public:
// Constructor
Student(string studentNumber, string initials, string surname, char sex) {
this->studentNumber = studentNumber;
this->initials = initials;
this->surname = surname;
this->sex = sex;
}
int main() {
// Enroll a student
Student student("123456789", "J", "Doe", 'M');
student.enrollModule("Math", 95);
student.enrollModule("Science", 87);
student.enrollModule("History", 72);
return 0;
}
ACTIVITY 1.2
#include <iostream>
#include <cmath>
class VoltageMaterial {
private:
double v0; // Maximum voltage
double k; // Gregg's surface number
double omega_p; // Peak angular frequency
double alpha; // Index current factor
double beta; // Material resistive factor
public:
// Constructor
VoltageMaterial(double v0, double k, double omega_p, double alpha, double
beta) {
this->v0 = v0;
this->k = k;
this->omega_p = omega_p;
this->alpha = alpha;
this->beta = beta;
}
int main() {
// Define the constants
double omega_p = 12.0; // rad/s
double alpha = 5.32;
double v0 = 50.0; // V
// Test case 1
double omega1 = 1800.0; // rad/s
double k1 = 0.15;
double beta1 = 1.5;
double partialVoltage1 = vm.PartialVoltage(omega1, k1, beta1);
cout << "Partial Voltage for omega = " << omega1 << " rad/s, k = " << k1 <<
", beta = " << beta1 << " is: " << partialVoltage1 << " V" << endl;
// Test case 2
double omega2 = 1500.0; // rad/s
double k2 = 1.5;
double beta2 = 1.1;
double partialVoltage2 = vm.PartialVoltage(omega2, k2, beta2);
cout << "Partial Voltage for omega = " << omega2 << " rad/s, k = " << k2 <<
", beta = " << beta2 << " is: " << partialVoltage2 << " V" << endl;
return 0;
}