0% found this document useful (0 votes)
32 views7 pages

OOP Assignment 1

1) The document describes an assignment to create a program for a hospital management system. 2) The program is required to store doctor records in an array of structures. It must allow the user to enter new records or view existing records. 3) The main function displays a login screen and menu. Based on the user's choice, it calls functions to enter new records or display records sorted by joining date.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views7 pages

OOP Assignment 1

1) The document describes an assignment to create a program for a hospital management system. 2) The program is required to store doctor records in an array of structures. It must allow the user to enter new records or view existing records. 3) The main function displays a login screen and menu. Based on the user's choice, it calls functions to enter new records or display records sorted by joining date.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

OOP Assignment 1

NAME: ASSAD ULLAH ARSHAD


ROLL NO: MCSM-F21-004
Subject Name: Object Oriented Programming
Language
Question:
Suppose you own a hospital, and you have 30 doctors appointed in the hospital. You need to maintain
the record of all the registered doctors and display their data when required. Create a structure Doctor,
containing registration number (int), name (char [] or string), address(nested), date of joining(nested) as
structure members. Write a program that accomplishes the following tasks: 1. Main function should ask
the user to enter id and password to proceed further. 2. Main function should display a menu either to
enter the record or display the record. Program should call the functions according to user’s choice. 3. If
user chooses to enter the record, program should store the data in a structure array of 30 members.
Program should ask the user if he wants to enter the next record. 4. If user chooses to display the record
and there is record present, program should display the list of record (in ascending order of date of
joining), if there is no record present then it should display a message of “no record found”. 5. Record
displayed by point number 4 should be sorted in descending order of date of joining of doctors by using
a sort function.

Solution:
#include<iostream>

#include<fstream>

#include<conio.h>

#include<string>

using namespace std;

struct doctors{

int reg_no,date;

string name,address;

};

void new_record(void);

void view_record(void);

int main()
{

doctors dr;

int password=12345;

string id = "assad";

cout<<"\t\t\t\t<----------------------------->"<<endl;

cout<<"\t\t\t\t<-----Welcome to Doctors------>"<<endl;

cout<<"\t\t\t\t<----By Assad Ullah Arshad---->"<<endl;

cout<<"\t\t\t\t<----------------------------->"<<endl;

cout<<"\t\tPlease Enter Your ID to Login "<<endl;

cout<<"\t";cin>>id;

if(id=="assad")

cout<<"\t\tEnter Your Password to continue "<<endl;

cout<<"\t";

cin>>password;

if(password==12345)

cout<<"\n\t\t Welcome Dr."<<id<<endl;

cout<<"\n\tPress 1 to enter a New Record: ";

cout<<"\n\tPress 2 to View An Existing Record: ";

cout << "\n\n\t\t\t ENTER YOUR CHOICE ";

int menu;

cout<<"\t";

cin>>menu;

if( menu == 1 | menu == 2 )

{
switch(menu)

case 1:

new_record();

break;

case 2:

view_record();

break;

else

cout << "\n\n\n\t\t\t PLEASE SELECT FROM THE OPTIONS GIVEN ABOVE , THANK YOU! \
n\n\n";

system("pause");

system("cls");

main();

else

cout<<"Invalid Password!"<<endl;

system("pause");
system("cls");

main();

else

cout<<"\t\tInvaid ID"<<endl;

cout << " Can't LOGIN \n USER NOT REGISTERED \n\n\n";

system("pause");

system("cls");

main();

return 0;

void new_record(void)

ofstream obj;

obj.open("record.txt");

string name[30];

string address[30];

int date[30];

int reg_no[30];

for(int i=0;i<3;i++)

cout<<"Pelase Enter Your Registrarion no ";


cin>>reg_no[i];

cout<<endl;

cout<<"Pelase Enter Your name ";

cin>>name[i];

cout<<endl;

cout<<"Pelase Enter Your Joining Date ";

cin>>date[i];

cout<<endl;

cout<<"Pelase Enter Your address ";

cin>>address[i];

cout<<"\n\n";

cout<<"If you want to enter a new record press Y \t";

int choice;

cin>>choice;

if( choice == 'y' | choice == 'Y')

for(int i=0;i<1;i++)

cout<<"Please Enter Required Information "<<endl;

cout<<"Pelase Enter Your Registrarion no ";

cin>>reg_no[i];

cout<<endl;

cout<<"Pelase Enter Your name ";

cin>>name[i];

cout<<endl;

cout<<"Pelase Enter Your Joining Date ";

cin>>date[i];

cout<<endl;
cout<<"Pelase Enter Your address ";

cin>>address[i];

else{

system ("pause");

system("cls");

main();

obj.close();

void view_record(void)

ofstream obj;

string name[30];

string address[30];

int date[30];

int reg_no[30];

int view;

cout<<"Please Enter your ID to view the record: ";

cin>>view;

cout<<endl;

for(int i=0;i<30;i++)

if(view==reg_no[i]){

cout<<"Your name is "<<reg_no[i];


cout<<endl;

cout<<"Your address is "<<name[i];

cout<<endl;

cout<<"Your Joining Date is "<<address[i];

cout<<endl;

cout<<"Your Registrarion no "<<date[i];

else{

cout<<"No record found"<<endl;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy