Sei sulla pagina 1di 16

Department of IT and Engineering

Computer Programming Technique Assignment

CONTENT 1. 2. 3. 4. 5. 6. 7. 8. Introduction Program Flow Chart Algorithm Program Documentation User Documentation Output References Bibliography 2 3 5 10 11 11 16 16

Student ID: 5507

Page 1 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Introduction:
This computer programming technique assignment is done as a part of my course work. This assignment consists of basic programming technique used to code the program. In this assignment I have document a program for the student registration system which have a section for new student registration and to read the registered student details. This assignment also consists of flow diagram which consists of different geometrical shapes.

Program Flow Chart:

Start

Initialising

Read Registered student Details

End

(Cogswell, 2005)

Student ID: 5507

Page 2 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Start

Select From the Menu

T Case 1:

Enter New Student Details

T Case 2:

Read Registered Students Details

Case 3:

Exit

T End

Cogswell, J. (2005) Cogswell, J. (2005)

Student ID: 5507

Page 3 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Start

Initialising

End

Select From the Menu

T Case 1:

Enter New Student Details

T Case 2:

Read Registered Students Details

Case 3:

Default

Student ID: 5507

Page 4 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Algorithm:
/*About: This program is written as part of the fulfilment for the Computer Programming Technique Course - HND in EEE at Icon College, London. Date : 18/08/2011 By : Naresh Poudel. Student ID: 5507 Tutor: Dr. Y M Gebremichael ******************************************************************** *****************/ #include <iostream> #include<string> using namespace std; /**************************** Initialising the variable ******************************/ int studentIDNumber, passportNumber; string firstName,lastName,dateofBirth,houseNumber; string maritalStatus,nationality,placeofBirth; string visaRequired,courseEnrolled; string streetName,townorCity,postCode,country; string save,y,n; /************************ Function Prototype *************************/ void Enternewstudentdetails(void); void Readregisteredstudentdetails(void); void exit(void); void menu(void); void reset(void); void main() { menu(); } /******************************************************************* ********************************** About: This Program choose the option from the menu option and take to the blog that you have chosen. ******************************************************************** ***********************************/ void menu(void) { int menu=0; cout<<".........................Menu.............."<<endl<<endl; cout<<"\t\t\t[1]. Enter New Students Details\n"<<endl; cout<<"\t\t\t[2]. Read Registered Student's Details\n"<<endl;
Student ID: 5507 Page 5 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

cout<<"\t\t\t[3]. Exit\n"<<endl; cout<<"..........................................."<<endl; cout<<endl; cout<<"Please select from the above menu: "; cin>>menu; /******************************************************************* ************ About: This program takes the first option as to enter the new student details. ******************************************************************** ************/ switch(menu) { case 1: { cout<<"[1]. Enter New Student's Details"<<endl<<endl; Enternewstudentdetails(); break; } /******************************************************************* ****************** About: This proram takes the second option as to read the registered student details. ******************************************************************** *******************/ case 2: { cout<<"[2].Read Registered Student's Details"<<endl<<endl; Readregisteredstudentdetails(); break; } /******************************************* About: This option exits the whole program. ********************************************/ case 3: { cout<<"[3].Exit"<<endl; exit(); break; } default: { break; } } }

Student ID: 5507

Page 6 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

void Enternewstudentdetails(void)/*Function defination*/ { cout<<"Student ID Number"<<endl; cin>>studentIDNumber; cout<<"First Name"<<endl; cin>>firstName; cout<<"Last Name"<<endl; cin>>lastName; cout<<"Date of Birth (DD/MM/YY)"<<endl; cin>>dateofBirth; cout<<"Maritial Status"<<endl; cin>>maritalStatus; cout<<"Nationality"<<endl; cin>>nationality; cout<<"Place of Birth"<<endl; cin>>placeofBirth; cout<<"PassportNumber"<<endl; cin>>passportNumber; cout<<"Visa Required (Y or N)"<<endl; cin>>visaRequired; cout<<"Course Enrolled"<<endl; cin>>courseEnrolled; cout<<"House Number"<<endl; cin>>houseNumber; cout<<"Street Name"<<endl; cin>>streetName; cout<<"Town or City"<<endl; cin>>townorCity; cout<<"PostCode"<<endl; cin>>postCode; cout<<"Country"<<endl; cin>>country; cout<<endl<<endl; system("cls");/* About: This program clear the screen*/ cout<<"If you want to save the detail press y or to discard press n"<<endl; cin>>save; menu(); if ( save==y)/* About: This program saves the details of the student*/ { cout<<"Student ID Number= "<<studentIDNumber<<endl; cout<<"First Name="<<firstName<<endl; cout<<"Last Name="<<lastName<<endl; cout<<"Date of Birth="<<dateofBirth<<endl; cout<<"Maritial Status="<<maritalStatus<<endl; cout<<"Nationality="<<nationality<<endl; cout<<"Place of Birth="<<placeofBirth<<endl;
Student ID: 5507 Page 7 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

cout<<"Passport Number="<<passportNumber<<endl; cout<<"Visa Required (Y or N)="<<visaRequired<<endl; cout<<"Course Enrolled="<<courseEnrolled<<endl; cout<<"House Number="<<houseNumber<<endl; cout<<"Street Name="<<streetName<<endl; cout<<"Town or City="<<townorCity<<endl; cout<<"PostCode="<<postCode<<endl; cout<<"Country="<<country<<endl; menu(); } else if ( save==n)/* About: This program discard the details entered*/ { system("cls"); reset();/*About: This program reset all the values entered*/ menu(); } } void Readregisteredstudentdetails(void) /*Function defination*/ { int studentIDNumber1=0; /* Initilising the variable*/ cout<<"Enter the student ID number: "<<endl; cin>>studentIDNumber1; if(studentIDNumber==studentIDNumber1) { cout<<"YOU ARE REGISTERED-------WELCOME TO COLLEGE------"<<endl<<endl; cout<<"Your Detail is given below"<<endl<<endl; cout<<"Student IDNumber= "<<studentIDNumber<<endl; cout<<"First Name="<<firstName<<endl; cout<<"Last Name="<<lastName<<endl; cout<<"Date of Birth="<<dateofBirth<<endl; cout<<"Maritial Status="<<maritalStatus<<endl; cout<<"Nationality="<<nationality<<endl; cout<<"Place of Birth="<<placeofBirth<<endl; cout<<"Passport Number="<<passportNumber<<endl; cout<<"Visa Required (Y or N)="<<visaRequired<<endl; cout<<"Course Enrolled="<<courseEnrolled<<endl; cout<<"House Number="<<houseNumber<<endl; cout<<"Street Name="<<streetName<<endl; cout<<"Town or City="<<townorCity<<endl; cout<<"PostCode="<<postCode<<endl; cout<<"Country="<<country<<endl; menu();
Student ID: 5507 Page 8 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

} else if (studentIDNumber1==5507) { studentIDNumber=5507; firstName="Naresh"; lastName="Poudel"; dateofBirth="1/01/1988"; maritalStatus="Single"; nationality="Nepalese"; placeofBirth="Kathmandu"; passportNumber=234567; visaRequired="Yes"; courseEnrolled ="Btec HND in Electrical/ Electronic Engineering(Communication)"; houseNumber="174"; streetName="Wilmount Street"; townorCity="London"; postCode="SE18 6RH"; country="United Kingdom";

cout<<"Student ID Number="<<studentIDNumber<<endl; cout<<"First Name="<<firstName<<endl; cout<<"Last Name="<<lastName<<endl; cout<<"Date of Birth="<<dateofBirth<<endl; cout<<"Maritial Status="<<maritalStatus<<endl; cout<<"Nationality="<<nationality<<endl; cout<<"Place of Birth="<<placeofBirth<<endl; cout<<"PassportNumber="<<passportNumber<<endl; cout<<"Visa Required="<<visaRequired<<endl; cout<<"Course Enrolled="<<courseEnrolled<<endl; cout<<"House Number="<<houseNumber<<endl; cout<<"Street Name="<<streetName<<endl; cout<<"Town or City="<<townorCity<<endl; cout<<"PostCode="<<postCode<<endl; cout<<"Country="<<country<<endl; menu(); } else { cout<<"YOU ARE UNREGISTERED"<<endl; menu(); } } void exit(void)/* Function defination as it exits the whole program*/
Student ID: 5507 Page 9 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

{ } void reset(void)/* Function defination as it reset the values*/ { studentIDNumber =0 ; passportNumber =0 ; firstName = ""; lastName = ""; dateofBirth = ""; houseNumber = ""; maritalStatus = ""; nationality = ""; placeofBirth = ""; visaRequired = ""; courseEnrolled = ""; streetName = ""; townorCity = ""; postCode= ""; country ="" ; } (Horton, 2006), (Wany, 2004)

Program Documentation
In the program function menu gives the user to select the appropriate section from the menu. I have used switch statements to select from the appropriate menu items. In the section one the program asks the user to input the different parts of the details. After the details are entered the program clears the screen and asks for the user to save or discard the details entered before. Here, if y is entered the details are saved and if n is entered the details are discarded. For this section I have used if else function as it help us to execute the statements of code in a different order, depending on certain conditions. In the read registered student details, I have again used if else statements to read the data that have input in the section. After the section executes the program as the user to enter the student ID number, if the id number matches or true with the details provided, it gives the relevant information, but if the student id is wrong or false, the program displays the message as YOU ARE UNREGISTERED. I have initialises my details as the default value, so if my student id number is entered the program gives my details. The next function is exit as it exits from the whole program. I have also used reset function to reset the values if the n is pressed the section 1 after the student details is entered. This discard the details used in section one. (Crawford, 2005) , (Deitel, 2005) For every menu item of the menu, I have grouped together to execute the program to make a function. Every function has to be declared outside the main function which is called as function prototype and every function has to call inside the main function. The variables that are used inside the function are different from the variables used in the main function. The scope of declared the variable within the function is their own function or block.

Student ID: 5507

Page 10 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

User Documentation:
As the program starts the menu item is displayed, which enables the user to use the different menu section. Section 1 requests the user to input the new student details and after the last item is entered, the program displays Yes or No prompt. If Yes is pressed, the details are saved temporarily, but if No is selected, the details are discarded. Section 2 gives the user details of the registered student. In the section 2, the program request the user to input the registered student ID number which after displays the registered student details. If the student ID number is incorrect the program displays YOU ARE UNREGISTERED message in the program. In the program my details are hardcoded in the system as the default values, if my student ID number is entered, the program displays my details. Section 3 exits the whole program.

Output:

Student ID: 5507

Page 11 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Student ID: 5507

Page 12 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Student ID: 5507

Page 13 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Student ID: 5507

Page 14 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

Student ID: 5507

Page 15 of 16

Department of IT and Engineering

Computer Programming Technique Assignment

References:
Cogswell, J. (2005) C++ cookbook, OReilly. Crawford,T.(2005) C in nutshell,OReilly. Deitel, H.M (2005) C++ how to program, Prentice hall. Horton, I. (2006)Beginning visual c++, Indiana: John Wiley. Wany, W. (2004) Beginning programming for dummies, 3rd ed, Indiana: John Wiley

Bibliography:
Davis, R (2010)Beginning Programming with C++ For Dummies.Wiley Publishing: Indiana. Henkmans, D.(2003)C++ Programming for the absolute beginner, Ptemier Press: London Lichade, M. V (2003) C programming, Dreamtec press. Perry, G. (2001)Sams Teach Yourself Beginning Programming in 24 hours, Sams Pulication: Los Angels. Veeraraghavan, S.(2002) Sams Teach Yourself Shell Programming in 24 hours, Sams Publication.

Student ID: 5507

Page 16 of 16

Potrebbero piacerti anche