0% found this document useful (0 votes)
12 views4 pages

CS 200 - Lab - 3

Lab 3

Uploaded by

seemarahat1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

CS 200 - Lab - 3

Lab 3

Uploaded by

seemarahat1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name Roll Number:

CS 200 Introduction To Programming


Fall 2022-2023
Lab

Lab # 3

Lab Guidelines
1. You are allowed to perform/submit the lab only during lab timings
2. Copying/sharing code is strictly prohibited. Using unfair means will lead to immediate
disqualification

Task 1 Logic Method 1 Method 2 Method 3 Method 4 Method 5 Total


10 5 5 10 10 10 50

Task 2 Logic Constructors Method 2 Method 3 Total


5 10 5 10 30

Task 3 Question 1 Question 2 Question 3 Question 4 Total


5 5 5 5 20

Obtained Marks: __________________________


Total Marks: 100

TA Signature: _____________________________
Task 1 - Money Heist [50 Marks]

In this question, you will simulate a bank’s customer data. Let’s create a struct called
“Customer”. Customer has three member variables: name (datatype : string), balance (datatype :
integer), account_type (datatype : char). There are two account types: Saving (represented as “S”
in account_type) and Current (represented as “C”).

Create a default constructor for Customer. [5 Marks]

Create a parameterised constructor for Customer. [5 Marks]


The parameterised constructor would have a parameter for name and account_type. Every
customer starts with a balance of 0.

Create a struct method, “AddBalance”. [10 Marks]


AddBalance will have one (1) parameter, which stores the balance to be added
(obviously). The method is going to have the following restrictions. A customer cannot add more
than $50,000 in one call. Display “Transaction Successful” if the balance is successfully added
and “Transaction Unsuccessful” otherwise.

Create a struct method, “WithdrawBalance”. [10 Marks]


WithdrawBalance will have no parameters (obviously). However, the method is going to
have the following restrictions. No customer can withdraw more balance than they have in the
account. Customer that has a savings account cannot withdraw more than $10,000 in one call.
Display “Transaction Successful” if the balance is successfully added and “Transaction
Unsuccessful” otherwise.

Create a struct method, “PrintDetails”. [10 Marks]


PrintDetails will have no parameters. The method prints the user details in the following
format:
This (saving/current) account belongs to (name). The account currently has $(balance).

Ex:
This current account belongs to Abdullah. The account currently has $0.

(You do not have to bold your output)

Task 2 - Time and Time Again [30 Marks]

In this task, you will be working with classes. Let’s create a class called Date. Date has three
private member variables: day, month and year.
Create a default and parameterised constructor. [5+5 Marks]

Create a class method, “Display”. [5 Marks]


This method displays the date in the following format: DD/MM/YYYY.

Create a class method, “IsLeapYear”. [10 Marks]


This method simply prints, “The date is (in/not in) a leap year.” You can assume that all
the years divisible by 4 but not divisible by 100 are leap years.

Ex: 2004 is a leap year, but 2000 is not a leap year.

Task 3 - Trace! Trace! [20 Marks]


#include <iostream>

using namespace std;

struct LUMS
{
private:
string school;
string name;
string rollNumber;
public:
LUMS()
{
cout << "LUMS - Not for Profit - University" << endl;
}

LUMS(string s, string n , string r)


{
cout << "Everyone calls me but no one asks me How am I?\n";
cout << s << "\n" << n << "\n" << r << endl;
school = s;
name = n;
r = rollNumber;
}
~LUMS()
{
cout << "I really miss the Pre-Covid LUMS" << endl;
}
};
void anotherFunction(LUMS HSS)
{
cout << "Humanity is a social construct\n";
LUMS anaconda("School of Demons and Social Bullies" , "Snake" , "I
won't tell");
}

void sadFunction()
{
LUMS happyStudent("School of Simple and Efficient Learning" ,
"HomoSapien" , "You know who I am");
cout << "If you look for the light you will often find it but if you
look for the dark that is all you will find.\n";
}

int main()
{
LUMS student("School of Stress and Existential Crisis" , "Human" , "Not
Known");
{
LUMS sadStudent;
anotherFunction(sadStudent);
}
sadFunction();
}

(You get a treat from Hassnain, if you answer this question correctly. Good Luck ^_^)
What is the output if the above program is executed?

You might also like