Pages

Saturday, July 7, 2012

2011 paper 2(a)

Question 01

//Header File

#include<iostream>
#include<cstring>
using namespace std;

class plane
{
private :
int planeNo;
char Airline[20];
char Destination[20];
int NoOfSeats;
int NoOfSeatsAvailable;
double Cost;

public:

plane(int pplaneNo,const char pAirline[],const char pDestination[],int pNoOfSeatsAvailable,double pCost);
void makeReservation(int planeNo,int seats_needed,int pNoOfSeatsAvailable,double pCost);
void print();

};

------------------------------------------------------------------------------------------------------------------

//Cpp File


#include "plane.h"

plane::plane(int pplaneNo,const char pAirline[],const char pDestination[],int pNoOfSeatsAvailable,double pCost)
{
planeNo=pplaneNo;
strcpy(Airline,pAirline);
strcpy(Destination,pDestination);
NoOfSeatsAvailable=pNoOfSeatsAvailable;
Cost=pCost;
}

void plane::makeReservation(int planeNo,int seats_needed,int pNoOfSeatsAvailable,double pCost)
{
if(NoOfSeatsAvailable<seats_needed)
{
cout<<"Seats not available.Cannot reserve"<<endl;
}
else if(NoOfSeatsAvailable>seats_needed)
{
cout<<"Reservation done !"<<endl;
double total=Cost*seats_needed;
cout<<"Total :"<<total<<endl;
}
else if(NoOfSeatsAvailable==0)
{
cout<<"Plane Full.Cannot make reservation."<<endl;
}
}

void plane::print()
{
cout<<"Plane No :"<<planeNo<<endl;
cout<<"Air line :"<<Airline<<endl;
cout<<"Destination :"<<Destination<<endl;
cout<<"No Of Seats Available :"<<NoOfSeatsAvailable<<endl;
cout<<"Cost :"<<Cost<<endl;

cout<<"**********************************************************"<<endl;
cout<<endl;
cout<<endl;
}

----------------------------------------------------------------------------------------------------------------------

//Main Program

#include "plane.h"

int main()

{

plane p1(2012,"Jet Airways","Singapore",0,25000.00);
p1.makeReservation(2012,5,0,25000.00);
p1.print();


plane p2(4521,"Sri Lankan","Malaysia",50,32000.00);
p2.makeReservation(2012,4,50,32000.00);
p2.print();

plane p3(6521,"Thai Airways","Bangkok",15,29000.00);
p3.makeReservation(6521,6,15,29000.00);
p3.print();

return 0;
}

-----------------------------------------------------------------------------------------------------------------------


H.K
07.07.12

2011 paper 1(b)

Question 3

//Header File

#include<iostream>
#include<cstring>
using namespace std;

class item
{

private :

int ItemNo;
char Category[30];
int NoOfItem;
int ItemsAvailable;

public :

item(int pItemNo,const char pCategory[],int pNoOfItem,int pItemsAvailable);
void issueItem(int pItemNo,int pNoOfItem,int pItemsAvailable);
void print();
};

-------------------------------------------------------------------------------------------------------------------

//Cpp File

#include "item.h"

item::item(int pItemNo,const char pCategory[],int pNoOfItem,int pItemsAvailable)
{
ItemNo= pItemNo;
strcpy(Category,pCategory);
NoOfItem=pNoOfItem;
ItemsAvailable= pItemsAvailable;
}

void item::issueItem(int pItemNo,int pNoOfItem,int pItemsAvailable)
{
if(ItemsAvailable>=1)
{
cout<<"Item available ,can be issued"<<endl;
}
else if(ItemsAvailable<1)
{
cout<<"Item not available "<<endl;
}
else if(NoOfItem==0)
{
cout<<"Item not in Library"<<endl;
}
}

void item::print()
{

cout<<"Item no :"<<ItemNo<<endl;
cout<<"Category :"<<Category<<endl;
cout<<"No of Items :"<<NoOfItem<<endl;
cout<<"Items Available "<<ItemsAvailable<<endl;

cout<<"**************************************************************************"<<endl;
cout<<endl;
cout<<endl;


}


-------------------------------------------------------------------------------------------------------------------


//Main program
#include "item.h"

int main()
{

item i1(21001,"Book",5,2);
i1.issueItem(21001,5,2);
i1.print();

item i2(31205,"Journal",3,1);
i2.issueItem(31205,3,1);
i2.print();

item i3(89025,"Magazine",0,0);
i3.issueItem(89025,0,0);
i3.print();


return 0;
}

------------------------------------------------------------------------------------------------------------------
                                                                                                                                                        
H.K
07.07.12

2011.paper 1(a)

Question 1



#include<ncurses.h>
void triangle(int startrow,int startcol,int height);
void rectangle(int startrow,int startcol,int height,int width);
int main()
{
initscr();
start_color();

init_pair(1,COLOR_GREEN,COLOR_YELLOW);
init_pair(2,COLOR_BLACK,COLOR_WHITE);
init_pair(3,COLOR_WHITE,COLOR_MAGENTA);
init_pair(4,COLOR_YELLOW,COLOR_BLUE);

attrset(COLOR_PAIR(1));
rectangle(5,20,4,11);

attrset(COLOR_PAIR(2));
rectangle(9,11,4,27);

attrset(COLOR_PAIR(3));
triangle(5,31,4);




attrset(COLOR_PAIR(4));
triangle(14,13,3);
triangle(12,17,2);
triangle(26,13,3);
triangle(12,29,2);

getch();
endwin();
return 0;
}
void triangle(int startrow,int startcol,int height)
{
if(height==4)
{
int a=0;
for(int i=startrow;i<startrow+height;i++)
{
for(int j=startcol;j<=startcol+a;j++)
{
move(i,j);
printw("*");
}
a++;
}
}
else if(height==3)
{
int b=0;
for(int i=startrow;i<startrow+height;i++)
{
for(int j=startcol;j<=startcol+b;j++)
{
move(j,i);
printw("*");
}
b++;
}
}
else
{
int c=0;
for(int i=startrow+height;i>startrow;i--)
{
for(int j=startcol;j<=startcol+c;j++)
{
move(i,j);
printw("*");
}
c++;
}

}
}

void rectangle(int startrow,int startcol,int height,int width)
{
for(int i=startrow;i<startrow+height;i++)
{
for(int j=startcol;j<startcol+width;j++)
{
move(i,j);
printw("*");
}
}
}




Question 2

// Header File

#include<iostream>
#include<cstring>

using namespace std;

class book
{
private :
int bookNo;
char type[30];
float UnitPrice;
int ReOrderLevel=10;
int StockInHand;

public:

book(int pbookNo,const char ptype[],double pUnitPrice,int pStockInHand);
void placeOrder(int pbookNo ,int Quantity);
void print();
};


---------------------------------------------------------------------------------------------------------------
//cpp File



#include "book.h"
book::book(int pbookNo,const char ptype[],double pUnitPrice,int pStockInHand)
{

bookNo= pbookNo;
strcpy(type,ptype);
UnitPrice=pUnitPrice;
StockInHand=pStockInHand;

}

void book::placeOrder(int pbookNo ,int Quantity)
{
int ReOrderLevel=10;

if(StockInHand<Quantity)
{
cout<<"Stock not available.Order cannot be pleced"<<endl;
}
else if(StockInHand>Quantity)
{
cout<<"order placed"<<endl;
double total=UnitPrice*Quantity;
cout<<"Total :"<<total<<endl;
}
else if (StockInHand<ReOrderLevel)
{
cout<<"Stock not enought,plece order"<<endl;
}
}

void book::print()
{

cout<<"Book no :"<<bookNo<<endl;
cout<<"Type :"<<type<<endl;
cout<<"Unit price :"<<UnitPrice<<endl;
cout<<"Stock in hand : "<<StockInHand<<endl;

cout<<"*********************************************************************************************************"<<endl;
cout<<endl;
cout<<endl;

}

----------------------------------------------------------------------------------------------------------------------------

//Main programe

#include "book.h"

int main()
{
book b1(1001,"Singular rule",58.50,50);
b1.placeOrder(1001,25);
b1.print();

book b2(1002,"Blank page",32.50,5);
b2.placeOrder(1002,10);
b2.print();

book b3(1003,"Square rule",48.00,15);
b3.placeOrder(1003,7);
b3.print();

return 0;
}

-----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Question 4



#include<iostream>
#include<cstring>
using namespace std;
void input(char arr[][10],int marks[],int size);
int findtop(const char arr[][10],int size);
int main()
{

char myarray[5][10];
int mymarks[5],top;

input(myarray, mymarks, 5);
top = findtop(myarray,5);
cout <<"Top name :"<< myarray[top] << " Marks : " << mymarks[top] <<"\n";
return 0;
}
void input(char arr[][10],int marks[],int size)
{
for(int i=0;i<size;i++)
{
cout<<"Enter Name :";
cin>>arr[i];
cout<<"Enter Marks :";
cin>>marks[i];

}
}
int findtop(const char arr[][10],int size)
{
int mark=0;
for(int i=0; i<size; i++)
{
if(strcmp(arr[mark],arr[i])> 0)
mark = i;

}
return mark;
}








Monday, May 21, 2012


වව්ලෙක් ඔබ අමතයි!

.
වව්ලාගේ ජයග්‍රාහි පළමු වෙනි බ්ලොග් ලිපියයි මේ! :ඩී
.
මුලින්ම කිව්වොත් මේක හැදුවේ අපි කාපු කට්ට කන එකෙන් SLIIT එකේ අනාගත පරපුර බේර ගන්න!! IPE වල Lab Exercises කරන්න ගියාම, programming ගැන මෙලෝ සංසාරයක් දන්නැතුව අපි අමු කට්ටක්නෙ කෑවේ! CF වල සතියෙන් කරන්න ඕනි Lab sheets කරගන්න බැරුව ඒ කට්ටම කෑවා!
.
ඒ කාලෙමයි අපි හිතුවෙ අපි කරපු IPE lab exercises, CF වල අපි හදපු lab sheet answers,  එතකොට තව past papers වලට අපි ලියපු උත්තර මෙහෙම නෙට් එකට දානවා කියල. හැබැයි මේවා කෙලින්ම copy කරලා විලි ලැජ්ජාවක් නැතුව moodle එකට  upload කරල ෂේප් වෙන්න නම් එපා!! දන්නැති, තේරෙන්නැති දේවල් ගැන පොඩි අදහසක් වත් ගන්න පුලුවන් වෙන්නයි මේවා දාන්නේ....
.
ආ තව දෙයක්! මේවා එකක් වත් official ඒවා නෙමේ!! ඒ කිව්වෙ තේරෙන සිංහලෙන් කිව්වොත් 'Use at your own Risk!!'. මේවා අපේ ගැන්සියේ බුවාලගේ වැඩ. ඉතින් අඩුපාඩු එහෙම ඇති! ගනන් ගන්න එපා හොඳේ!
.
ආ අපි තාම 1st year නේ! 1st සෙමෙස්ටර් එක ඉවර උනා විතරයි! ඉතින් තාම දාන්න පුලුවන් අපි කරපු ටික, ඒ කියන්නේ 1st year, 1st semester එකේ වැඩ විතරයි. අපිට මොන ජිල්මාට් එකක් හරි දාල අවුරුදු 4ම ඉන්න පුලුවන් උනොත්, ඒ යන ගමන් අපි කරන ඒවා upload කරන්නන්කෝ හොඳේ!


-Jericho