Computer Systems Engineering: Structures and Classes in C++ Assignment

Verified

Added on  2021/07/28

|10
|541
|208
Homework Assignment
AI Summary
This document presents a comprehensive solution to a C++ programming assignment focusing on structures and classes. The assignment includes several practical tasks: creating a phone number structure and displaying phone numbers, developing a movie database using structures, creating a coordinate system and drawing a rectangle using structures, building a student information system using structures, and designing a custom class with constructors, member functions, data members, and a destructor. The solution provides code and output for each task, demonstrating the application of these fundamental C++ concepts. The assignment is from the University of Engineering and Technology, Peshawar, and showcases the practical implementation of structures and classes in C++ programming.
Document Page
Computer Programming Lab
spring 2021
Submitted by: ADNAN AYAZ
Registration No.: 20PWCSE1860
Class Section: A
“On my honor, as student of University of Engineering and Technology, I have neither given
nor received unauthorized assistance on this academic work.”
Student Signature: ______________
Submitted to:
SIR ABDULLAH HAMID
JULY 25, 2021
Department of Computer Systems Engineering
University of Engineering and Technology, Peshawar
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Lab 10 &;11: Structures and Classes
Objectives:
To learn about data structures and classes in C++
Tasks:
Task 1:
1. 1. A phone number such is (091) 767-8900 can be thought of as having three parts: the area
code (091), exchange (767) and number 8900. Write a program that uses structure to
store these 3 parts of a phone number separately. Assume name of the structure is
‘phone’. Create two objects of type ‘phone’, initialize one object and take the other one
from the user. Display both numbers.
Sample Run:
Enter you Area code, exchange, and number: 091 767 8900
My number is (042) 867-4982
Your number is (091) 767-8900
CODING:
Document Page
OUTPUT:
Document Page
Task 2:
2. Write a C++ Program where you create a movie database using structures. i.e the struct
must have two members “title” and “year”. For test run add 3 movies into the database
and then display the move title and names.
CODING:
OUTPUT:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Task 3:
3. A point on a two-dimensional space has two numbers: an ‘X’ coordinate and a ‘Y’
coordinate such as (4, 5). Write a program that uses a structure called ‘point’ to model a
point and draw a rectangle of ‘*’ based on the entered height and width of the rectangle.
Sample Run:
Enter the point coordinates: (x, y)
3 2
Enter width of the rectangle: 3
Enter Height of the rectangle: 2
* * *
* * *
CODING:
Document Page
OUTPUT:
Document Page
Task 4:
4. Write a program to develop student information system. This system should be able to
take the student’s credentials, like name, reg no and semester no, as input and store them
in a structure object Student. The system should be capable of storing the information
of multiple students.
And it should be capable of displaying the student’s information, when asked to do so,
via reg no.
.
CODING:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
OUTPUT:
Document Page
Task 5:
Make a C++ Program that will have a Class of your choosing. You can pick your own
concept it doesn’t need to be a specific Class (for example we in lab we made a class
about rectangle choose anything like that). Your class must contain the following:
 Constructor
 Member functions
 Data members
 Destructor
CODING:
OUTPUT:
Document Page
chevron_up_icon
1 out of 10
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]