Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Assignment 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

CE101T – Object Oriented Programming

Section: Assignment # 2 Total marks: 35

Name : __________________ Roll number : __________________

Submission:
• Email instructor or TA if there are any questions. You cannot look at others’ solutions or use
others’ solutions, however, you can discuss it with each other. Plagiarism will be dealt with
according to the course policy.
• Submission after due time will not be accepted.

Follow this naming convention for your report, it should highlight difficulties you faced and things you
learned in this assignment. Naming Pattern ( Roll#_Assignment#.pdf e.g BSCE23000_Assignment3.pdf )
In this assignment you have to do following tasks:
Task 1: Ensure that you have installed all three softwares in your personal computer (Github,
Cygwin & CLion). Now, accept the assignment posted in Google Classroom and after accepting,
clone the repository to your computer. Make sure you have logged into the github app with your
account.
Task 2: Open Cygwin app, Move to your code directory with following command “cd
<path_of_folder>”
<path_of_folder> can be automatically populated by dragging the folder and dropping it to the
cygwin window.
Run the code through Cygwin, use command “make run”, to get the output of the code
Task 3: Solve the given problems, write code using CLion or any other IDE.
Task 4: Keep your code in the respective git cloned folder.
Task 5: Commit and Push the changes through the Github App
Task 5: Write the code in separate files (your_structure_name.h, your_structure_name.cpp) for each
struct(name must be singular), declare struct variables, and call functions from main.cpp. Ensure that
file names are in lowercase.
Task 6: Run ‘make run’ to run C++ code
Task 7: Run ‘make test’ to test the C++ code

Object Oriented Programming


CE101T-Spring 2024
Problem Statement: Student Records Management
Define a Student structure with the following attributes:

name: A string representing the student's name.


rollnumber: A string representing the student's roll number.
department: A string representing the student's department.
gpas: An array of 8 floats representing the student's GPAs in 8 different courses.

Part 1: Constructor
Define default constructor and parameterized constructor to initialize the properties of the
Student structure. Both constructor should print format: “Constructor Function is Called”.
1. Student()
2. Student(string n, string rn, string dept, float *gpas);

Part 2: Member Function to Extract First Name & Last Name


Create a function within a structure that accepts a user choice (bool type) as a parameter. This
function will extract the first name and last name from a full name (e.g., "Shams Farooq").
Depending on the user choice, it will print the total number of characters in the first name and
last name in the format: "Total characters in the first name are: 5" and "Total characters in the
last name are: 6". Finally, the function will return the first name and last name separately.
string Student::extractFirstLastNames(bool choice);

Part 3: Member Function to Convert Department Name


Create a function within a class that accepts a user choice (uppercase or lowercase) as a
parameter. This function will convert the department name (e.g., "Department of Computer
Engineering") accordingly and print it in the format: "DEPARTMENT OF COMPUTER
ENGINEERING" if the user choice is uppercase, or "department of computer engineering" if the
user choice is lowercase. Additionally, the function will count and print the total number of
vowels in the department name in the format: " Total Vowels in Department Name are: 12".
void Student::convertDepartmentName(string choice);
Note: Implement the member function using ASCII codes (built in functions not allowed)

Object Oriented Programming


CE101T-Spring 2024
Part 4: Member Function to Extract Numerical Part of Roll
Number
Create a function in the Student class that finds and returns the numeric part of a roll
number(format: bsce23001). In our roll number format, the first four characters indicate the
department code, followed by a numeric part. The function should focus on extracting and
returning only the numeric part of the roll number and also print the department code in the
format: “Department Code: BSCE”
string Student::extractRollNumber();
Note: Implement the member function using ASCII codes (built in functions not allowed)

Part 5: Non-Member Function to Calculate CGPA


Create a function that calculates the cumulative grade point average (CGPA) of a student. This
function should ask the user for the number of semesters they want to calculate the CGPA for.
After receiving the input, the function should calculate the CGPA based on the grades provided
for each semester and return the result.
float calculateCGPA(Student s, int num_of_semester);

Object Oriented Programming


CE101T-Spring 2024

You might also like