Posts

Digital Clock using c++

Digital Clock using c++  #include<iostream> #include<Windows.h> using namespace std; int main() { int hr,min,sec,a=0; cout<<"PLease enter the hr:";cin>>hr; cout<<"Please enter the min:";cin>>min; cout<<"Please Enter the sec:";cin>>sec; while(a==0) { system("cls"); cout<<"Time is:"<<hr<<":"<<min":"<<sec<<endl; sec++; Sleep(1000); if(sec>59) { min++; sec=0; } if(min>59) { hr++; min=0; } if(hr>11) { hr=0; } } getchar(); getchar(); return 0; }

Phone Directory Management system with documentation in MIPS

 Phone Directory Management system with documentation Introduction:                          My management system is based in assembly language MIPS. So, I made a phone directory as a management system using MIPS and the uses of this management system is time that first, the main thing is this that it is more faster than the other management system because this is based on the MIPS and MIPS is more faster than the other programming languages because this is more closer to processor. In other programming languages compilers convert the code firstly into the assembly language with the help of assembler and then machine code therefore this is faster than this saves this time which other programming languages uses. And this is the biggest advantage of this management system and the other advantage is this that this is more optimized than the other programming languages because this consumes less memory because in this management system there is nothing extra instructions and less data

String and objects in c++

 String and objects in c++ #include<iostream> #include<string> using namespace std; class Pk_Songs { private: string Name[10]; public: void setname(){ const int size = 5; Pk_Songs a[size]; a[0].Name[0] = "Yeh mumkin to nhi"; a[0].Name[1] = "Saiyan"; a[0].Name[2] = "Aye dil tu bata"; a[0].Name[3] = "Mohobat tujhe alvida"; a[0].Name[4] = "Bharosa"; a[0].Name[5] = "Tu kya jaany"; a[0].Name[6] = "Kaheen deep jale"; a[0].Name[7] = "Tum se he taluq hai"; a[0].Name[8] = "Deewangi"; a[0].Name[9] = "Kahan jaye ye dil"; a[1].Name[0] = "Billo"; a[1].Name[1] = "Chamkeeli"; a[1].Name[2] = "Preeto"; a[1].Name[3] = "Nachaan main odey naal"; a[1].Name[4] = "Ballay ballay"; a[1].Name[5] = "Mela wekhan aiyan kudiyan Lahore diyan"; a[1].Name[6] = "Nach punjaban"; a[1].Name[7] = "Teri gal k

Case Study (Quarantine Center Management System) in oop in c++

  Quarantine Center Management System As you know now a days the world is going through the COVID-19 pandemic. People are getting themselves tested to see if they have corona virus or not. If they have positive result they are being isolated in Quarantine Centers for 14 days and if recovered, they are sent to their homes with safety precautions (same for negative results they are sent to their homes). In view of this scenario you have to use object oriented programming concepts to manage the patients in quarantine center. Now let’s see the management in center: There is a Quarantine Center in which Patients are admitted in case they are declared positive with Corona Virus after having a test. To do so, there is a class named Quarantine_Center having data member(s) center_id, location, quantity_of_beds (should be defined by default i.e. 20), no_of_patients and contact number . Person contains person_id (unique), first_name, last_name, gender, age and blood_group . A Patient is inher

Election votes Calculator in c++ using oop

Elections Votes Calculator Pakistan is going to conduct elections this year for the seat of Member of Provisional Assembly (MPA) the candidates that are taking part in election are: 1.     Imran Khan 2.     Sheikh Rasheed 3.     Nawaz Shareef 4.     Maryam Nawaz 5.     Benazir Bhutto Each of these participants earned votes from people. On the number of votes earned it is to be decided who won the elections. Considering this scenario draw a class diagram and then implement code in C++ having classes with data members, member functions and constructors as identified in class diagram. Sample outputs attached below. //Output #1   Enter Candidate #1 Name: Imran Khan Votes Earned by Imran: 8806 Enter Candidate #2 Name: Sheikh Rasheed Votes Earned by Sheikh: 5056 Enter Candidate #3 Name: Nawaz Shareef Votes Earned by Nawaz: 4500 Enter Candidate #4 Name: Maryam Nawaz Votes Earned by Maryam: 5026 Enter Candidate #5 Name: Benazir Bhutto Votes Earned by Benazir: 6602   ************************ Re

Exception Handling in oop(object oriented programming) in c++

 Exception Handling   Task 1: Write a program that prompts the user to enter a length in feet and inches and outputs the equivalent length in centimeters. If the user enters a negative number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. #include<iostream> using namespace std; class A{ double feet, inches; public: void in() { cout << "Enter the length in feet:"; cin >> feet; cout << "Enter the length in inches:"; cin >> inches; } void cent() { try{ if (feet > 0) { cout << "Feets in centimeters are:" << feet*30.48 << endl;

Templates and its types in oop(object oriented programming)

Templates Task 1: Write a template function that returns the average of all the elements of an array. The arguments to the function should be the array name and the size of the array (type int). In main(), exercise the function with arrays of type int, long, double, and char. #include<iostream> using namespace std; template <class T> class Average{ T *arr; int index; public: Average() { index = 0; } Average(int a,T *b) { index = a; arr = new T[index]; arr = b; } void ave() { T sum = 0,average; for (int i = 0; i < index; i++) { sum = sum + arr[i

Composition and aggregation in oop(object oriented programming)

 Composition and aggregation Create a class Distance having a member meter. Now create a friend function named convert() that increments meter by 5 and then converts that meter in kilo meters and return the answer. Call the function in main.    #include<iostream> using namespace std; class Distance{ float meter; friend void convert(Distance &d1) { d1.meter++; d1.meter = d1.meter / 1000; cout << "Meter in killometer is:" << d1.meter << endl; } public: Distance(){ meter = 5; } }; int main() { Distance d1; convert(d1); getchar(); getchar(); return 0; }   Task 2: Implement the classes according to the given class diagram. It shows both the composition and aggregation relationships. Driver h

Run time and compile time polymorphism in oop(object oriented programming)

 polymorphism Task 1 Create parent class Polygon with protected parameters width and height and function printarea() and a virtual function area(). Create three sub classes Rectangle , Square and Triangle.In main() create 3 pointers of Polygon and assign Rectangle , Square and Triangle to it. Call printarea function with the pointers. #include<iostream> using namespace std; class Polygon{ protected: int width, height; public: void printArea() { cout << "This is the area of Polygon" << endl; } virtual void area() { cout << "This is virtual area" << endl; } }; class Rectangle :public Polygon{ public: void area() { cout << "This is the area of Rectangle" << endl; } void printArea() {

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

 Multiple inheritance,friend function and     multiple file Task 1 Create Class Person with variables weight,height, gender. Create another Class Employee with variables designation, HoursPerDay. Now create another class Teacher and inherit it from Person and Employee and add function display() which should show all the details related to teacher. #include<iostream> #include<string> using namespace std; class Person{ int weight, height; string gender; public: Person() { weight = height = 0; gender = "0"; cout << "Default person" << endl; } }; class Employee{ string designation; int hourPerRate; public: Employee(){ designation = "0"; hourPerRate = 0;