Selasa, 01 Desember 2009

SET BOX

/*----------------------------------------------------------------------------
SETTING BOX
----------------------------------------------------------------------------*/
#include
#include
#include
//=============================================================================
// deklarasi class box

class Box {
private :
int length; // panjang
int width; // lebar
public :
Box(){ //constructur
length=15;
width =10;}
void setBox(int xwidth,int xlength){
length = xlength;
width = xwidth;}
int getlength() // melihat berapa panjang box
{int l;l=length;return(l);}
int getwidth() // melihat berapa lebar box
{int w;w=width;return(w);}
int getArround()// menghitung keliling box
{int Ar;Ar=(length+width)*2;return(Ar);}
int getArea() // menghitung luas box
{int A;A=length*width;return(A);}
void display();
};

void Box::display(){
int i,x1,x2,y1,y2;
x1=2;y1=2;x2=getwidth();y2=getlength();
for(i=y1+1;i<=y2-1;i++){gotoxy(i,x1);printf("%c",205);gotoxy(i,x2);printf("%c",205);}
for(i=x1+1;i<=x2-1;i++){gotoxy(y1,i);printf("%c",186);gotoxy(y2,i);printf("%c",186);}
gotoxy(y1,x2);printf("%c",200);gotoxy(y1,x1);printf("%c",201);
gotoxy(y2,x1);printf("%c",187);gotoxy(y2,x2);printf("%c",188); }

void main(){
Box b1;
Box b2;
b2.setBox(15,45);
cout<<"\n RINCIAN BOX : \n";
cout<<"\n Box 1 : PANJANG : "< cout<<"\n LEBAR : "< cout<<"\n KELILING : "< cout<<"\n LUAS : "<cout<<"\n\n Box 2 : PANJANG : "< cout<<"\n LEBAR : "< cout<<"\n KELILING : "< cout<<"\n LUAS : "<cout<b1.display();
getch();
}

BOX GOTO XY

/*----------------------------------------------------------------------------
MOH SHOLIHUDDIN
SETTING BOX
----------------------------------------------------------------------------*/
#include
#include
#include
//=============================================================================
// deklarasi class box
const ataskiri =201;
const ataskanan =187;
const bawahkiri =200;
const bawahkanan=188;
const rata =205;
const tegak =186;
const spasi =32;

class Box {
private :
int xpos;
int ypos;
int length; // panjang
int width; // lebar
public :
Box(){ //constructur
xpos = 5;
ypos = 5;
length =10;
width =5;}
void setBox(int xwidth,int xlength){
length = xlength;
width = xwidth;}
void display();
};

void Box::display(){
int i,j,n;
gotoxy(xpos,ypos);
printf("%c",ataskiri);
for(i=0;i printf("%c",rata);
printf("%c\n",ataskanan);

for(j=0;j gotoxy(xpos,ypos);
printf("%c",tegak);
for(i=0;i printf(" ",i);
printf("%c\n",tegak);n=n++}

printf("%c",bawahkiri);
for(i=0;i printf("%c",rata);
printf("%c",bawahkanan);

}

void main(){
Box b1;
Box b2;
b2.setBox(16,46);

b2.display();
//b1.display();
getch();
}
/*-------------------------
program utama (1)
penjumlahan
dgn parameter
-------------------------*/
#

//--deklarasi fungtion pemanggilan--
void inputdata(int *x,int *y);
void penjumlahan(int x,int y,int *z);
void cetak(int z);
int *x,*y,*z; //----deklarasi variable global--
void main()
{
int A=0,B=0,C=0;
cout<<"program penjumlahan"<<
cout<<"==================="<<
inputdata(&A,&B); //--pemanggilan fungtion input data--
penjumlahan(A,B,&C); //--pemanggilan fungtion penjumlahan--
cetak(C); //--pemanggilan fungtion cetak---
getch();
}
void inputdata(int *x,int *y)
{
cout<<"inputkan bilangan pertama : ";
cin>>*x;
cout<<"inputkan bilangan kedua : ";
cin>>*y;
}
void penjumlahan(int x,int y,int *z)
{
*z=x+y;
}
void cetak(int z)
{
cout<<"hasil penjumlahan : "< }










#include
#include
#include
struct mh
{
char nim[6];
char nama[11];
unsigned nilai;
};
void main()
{
struct mh mhs[10];
int i,n,d;
//--------input data---------------
puts("PROGRAM DATA MAHASISWA");
puts("----------------------");
cout<<" input banyaknya data : ";
cin>>n;
for(i=0;i{
d=i+1;
cout<<"\n\n data ke- "<cout<<"NIM : ";
cin>>mhs[i].nim;
cout<<"NAMA : ";
cin>>mhs[i].nama;
cout<<"NILAI : ";
cin>>mhs[i].nilai;
}
//---------cetak------------------
puts("\n\n DATA MAHASIAWA");
puts("-------------------\n");
puts(" NIM NAMA NILAI ");
puts("------------------------------");
for(i=0;i<=n-1;i++)
{
printf("%-5s %-10s %5u\n",mhs[i].nim,mhs[i].nama,mhs[i].nilai);
puts("------------------------------\n");
}
getch();
}