Thursday, February 12, 2009

Exercise 7

Output


Getting started


A-B


C-D


E


#include
#include
#include
void menu();
void nextscreen();
void nextscreen2();

void nextscreen()
{
clrscr();
int x,y,z;
for(x=1;x<=77;x++)
{
gotoxy(2+x,1);textcolor(GREEN);cprintf("Í");
//delay (10);
gotoxy(2+x,21);textcolor(GREEN);cprintf("Í");
//delay (10);
}
for(y=1;y<=20;y++)
{
gotoxy(3,1+y);textcolor(GREEN);cprintf("º");
//delay (10);
gotoxy(79,1+y);textcolor(GREEN);cprintf("º");
//delay (10);
}
gotoxy(3,1);textcolor(GREEN);cprintf("É");
gotoxy(3,21);textcolor(GREEN);cprintf("È");
gotoxy(79,1);textcolor(GREEN);cprintf("»");
gotoxy(79,21);textcolor(GREEN);cprintf("¼");
}
void menu()
{
nextscreen();
nextscreen2();
int choice,a,b,n,y,sum=0,sub=0,mul=0,div=0,z;
gotoxy(30,2);textcolor(LIGHTRED);cprintf("Exercise VII");
gotoxy(30,5);textcolor(LIGHTGREEN);cprintf("WeLcomE!!");
gotoxy(26,6);textcolor(LIGHTRED);cprintf("\nSelect operation you like to Try!");
gotoxy(25,8);textcolor(YELLOW);cprintf("\n\t[A] for ADDITION");
gotoxy(25,9);textcolor(BLUE);cprintf("\n\t[B] for SUBTRACTION");
gotoxy(25,10);textcolor(CYAN);cprintf("\n\t[C] for MULTIPLICATION");
gotoxy(25,11);textcolor(RED);cprintf("\n\t[D] for DIVISION");
gotoxy(25,12);textcolor(GREEN);cprintf("\n\t[E] for Exit");
gotoxy(25,14);textcolor(YELLOW);cprintf("\nEnter your choice operation here:");
scanf("%s",&choice);

switch(choice)
{
case 'A':

clrscr();

nextscreen();
nextscreen2();
gotoxy(25,5);textcolor(CYAN);cprintf("A] Addition");
gotoxy(25,6);textcolor(CYAN);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(CYAN);cprintf("Enter 2nd number:");
scanf("%d",&b);
sum=a+b;
gotoxy(25,10);textcolor(CYAN);cprintf("Sum of two number is: %d",sum);
gotoxy(25,12);textcolor(CYAN);cprintf("NicE onE!!\n");
gotoxy(25,14);textcolor(CYAN);cprintf("Do you want to try again,y/n?");
scanf("%s",&z);
menu();
getch();

break;
}

switch(choice)
{
case 'B': clrscr();
nextscreen();
nextscreen2();
gotoxy(25,5);textcolor(YELLOW);cprintf("B] Subtraction");
gotoxy(25,6);textcolor(YELLOW);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(YELLOW);cprintf("Enter 2nd number:");
scanf("%d",&b);
sub=a-b;
gotoxy(25,10);textcolor(YELLOW);cprintf("Subtraction of two number is: %d",sub);
gotoxy(25,12);textcolor(YELLOW);cprintf("NicE onE!!");
gotoxy(25,14);textcolor(YELLOW);cprintf("Do you want to try again,y/n?");
scanf("%s",&z);
menu();
getch();

break;
}

switch(choice)
{
case 'C':
clrscr();
nextscreen();
nextscreen2();
gotoxy(25,5);textcolor(BLUE);cprintf("C] Multiplication");
gotoxy(25,6);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(BLUE);cprintf("Enter 2nd number:");
scanf("%d",&b);
mul=a*b;
gotoxy(25,10);textcolor(BLUE);cprintf("Muliplication of two number is: %d",mul);
gotoxy(25,12);textcolor(BLUE);cprintf("NicE onE!!");
gotoxy(25,14);textcolor(BLUE);cprintf("Do you want to try again,y/n?");
scanf("%s",&z);
menu();
getch();

break;
}

switch(choice)
{
case 'D':
clrscr();
nextscreen();
nextscreen2();
gotoxy(25,5);textcolor(RED);cprintf("D] Division");
gotoxy(25,6);textcolor(RED);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(RED);cprintf("Enter 2nd number:");
scanf("%d",&b);
div=a/b;
gotoxy(25,10);textcolor(RED);cprintf("Division of two number is: %d",div);
gotoxy(25,12);textcolor(RED);cprintf("NicE onE!!");
gotoxy(25,14);textcolor(RED);cprintf("Do you want to try again,y/n?");
scanf("%s",&z);
menu();
getch();

break;
}



switch(choice)
{
case'E':

gotoxy(15,18);textcolor(LIGHTRED);cprintf("\n\nEnd of the program,Tinkchoi for browsing!! (-_-)");

}


}
void nextscreen2()

{
clrscr();
int a,b,x,y,z;

for(x=1;x<=77;x++)
{
gotoxy(2+x,1);textcolor(GREEN);cprintf("Í");
gotoxy(2+x,21);textcolor(GREEN);cprintf("Í");
}
for(y=1;y<=20;y++){
gotoxy(3,1+y);textcolor(GREEN);cprintf("º");
gotoxy(79,1+y);textcolor(GREEN);cprintf("º");
}
gotoxy(3,1);textcolor(GREEN);cprintf("É");
gotoxy(3,21);textcolor(GREEN);cprintf("È");
gotoxy(79,1);textcolor(GREEN);cprintf("»");
gotoxy(79,21);textcolor(GREEN);cprintf("¼");
for(a=1;a<=49;a++)
{
gotoxy(15+a,4);textcolor(MAGENTA);cprintf("¯");
gotoxy(15+a,17);textcolor(MAGENTA);cprintf("¯");
}
for(b=1;b<=14;b++)
{
gotoxy(16,3+b);textcolor(MAGENTA);cprintf("¯");
gotoxy(65,3+b);textcolor(MAGENTA);cprintf("® ");
}
}
void main()
{
clrscr();

nextscreen();
nextscreen2();
menu();
getch();

}

No comments: