Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==================this programme was done by=======================
- //================a.s.ram narayanan================================
- note:THIS WORKS only IN TURBO C++
- /*In this program 6 sub programs are clubbed together where the
- program does the following
- 1.displays a menu
- 2.asks for value to implement the following program accordingly
- 3.consists of six programs which are displayed in the menu itself
- working
- The working is based on simple function calling feature
- according to the value the particular the function is implemented
- */
- #include<iostream.h>
- #include<conio.h>
- #include<stdlib.h>
- #include<graphics.h>
- #include<dos.h>
- #include<stdio.h>
- #include<math.h>
- #define address_count 4
- void graphic_menu();//menu graphics prototype(not to be confused with void menu)
- void solarsys(); //solarsys protoype
- void address_book(); //address book prototype
- void numbers_to_words(); //numbers into words programme prototype
- void smiley();//smiley programme
- void moving_bus(); //moving bus progamme
- void moving_train();//moving train programme
- void calc(); /*scientific calculator program function porotypes*/
- double cores (double);
- double res (double);
- float sub(float,float);
- float div(float,float);
- float mul(float,float);
- float add(float,float);
- float ramp(float,float);
- double modulus(double);
- void menu();//sci fi calculator protoype
- float a,b,c,ch; //globl variable sfor scienfi calculator
- int ch1;
- int n1,n2,n3,n4,n5;//declaring global variables for numbers to words
- void main() //THE MAIN
- {
- clrscr();
- int gdriver=DETECT,gmode;
- initgraph(&gdriver,&gmode,"C://TC//bgi");
- int ch;
- graphic_menu();
- gotoxy(10,20);
- cin>>ch;
- if(ch==1)
- {
- solarsys();
- }
- else if(ch==2)
- {
- address_book();
- }
- else if(ch==3)
- {
- calc();
- }
- else if(ch==4)
- {
- numbers_to_words();
- }
- else if(ch==5)
- {
- smiley();
- }
- else if(ch==6)
- {
- moving_bus();
- }
- else if(ch==7)
- {
- moving_train();
- }
- else
- {
- cout<<"sorry out of cridentials";
- }
- getch();
- closegraph();
- }
- void graphic_menu()//menu function
- {
- setfillstyle(SOLID_FILL,BLUE);
- bar(0,10,300,250);//COLORED RECTANGLE(blue main)
- setfillstyle(SOLID_FILL,BROWN);//small rectangle for menu(only for text)
- bar(20,20,150,50);//small bar
- //setcolor(GREEN);//for rctabgle border(small one)
- rectangle(20,20,150,50);//border(small)
- settextjustify(30,5);
- settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
- outtextxy(30,5,"menu");
- setcolor(WHITE);//outline color for rectangle
- rectangle(0,10,300,250);//border of rectangle
- /* == TEXT FOR SOLAR SYSTEM===*/
- settextjustify(0,60);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
- outtextxy(0,60,"1.solarsystem(bgi)");
- /*==text for address book==*/
- settextjustify(0,80);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
- outtextxy(0,80,"2.addressbook(underconstruct)");
- /*==text for scientific calculator===*/
- settextjustify(0,100);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
- outtextxy(0,100,"3.sci-fi calc(withno inbuilt fn)");
- /*==text for NUMBERS TO WORDS===*/
- settextjustify(0,120);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
- outtextxy(0,120,"4.numbers to words");
- /*==text for smiley===*/
- settextjustify(0,140);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
- outtextxy(0,140,"5.smiley(bgi)");
- /*==text for bus===*/
- settextjustify(0,160);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
- outtextxy(0,160,"6.moving bus(bgi)");
- /*==text for train===*/
- settextjustify(0,180);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
- outtextxy(0,180,"7.moving train(bgi)");
- /*==text for choice===*/
- settextjustify(0,210);
- settextstyle(SMALL_FONT,HORIZ_DIR,5);
- outtextxy(0,210,"ENTER YOUR CHOICE 1/2/3/4/5/6/7");
- }
- void solarsys()//solarsys function
- {
- for(int i=0;i<20;i++)
- {
- setcolor(i+1);
- delay(100);
- settextjustify(100,50);
- settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
- outtextxy(100,50,"MAGIC OF GRAPHICS.h");
- settextjustify(100,100);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
- outtextxy(100,100,"by ram");
- }
- printf("\n\n\n\n");
- setcolor(RED); //FOR THE CENTRE CIRCLE
- setfillstyle(SOLID_FILL,BROWN);
- circle(300,300,120);
- floodfill(300,300,RED);
- setcolor(WHITE); //FOR ORBIT PATH ELLIPSE 1
- ellipse(300,300,0,360,200,70);
- setcolor(BLUE); //FOR PLANET 1(YELLOW WITH BLUE BORDER)
- setfillstyle(SOLID_FILL,YELLOW);
- circle(400,350,30);
- floodfill(400,350,BLUE);
- setcolor(WHITE); //FOR ORBIT PATH ELLPSE 2
- ellipse(300,300,0,360,250,80);
- setcolor(GREEN); //FOR PLANET 2(BLUE WITH GREEN BORDER)
- setfillstyle(SOLID_FILL,BLUE);
- circle(550,300,30);
- floodfill(550,300,GREEN);
- setcolor(WHITE);
- ellipse(300,300,0,360,300,90); //FOR ORBIT PATH ELLIPSE 3
- setcolor(BLUE);
- setfillstyle(SOLID_FILL,CYAN); //FOR PLANET 3 (GREEN WITH BLUE BORDER
- circle(100,300,30);
- floodfill(100,300,BLUE);
- setcolor(WHITE);
- ellipse(300,300,0,360,310,95);
- setcolor(GREEN);
- setfillstyle(SOLID_FILL,WHITE); //FOR PLANET 4 (GREEN WITH BLUE BORDER
- circle(40,300,25);
- floodfill(40,300,GREEN);
- setcolor(RED); //for lightgreen planet with red border
- setfillstyle(SOLID_FILL,LIGHTGREEN);
- circle(540,250,20);
- floodfill(540,250,RED);
- setcolor(YELLOW); /*FOR THE SUN TEXT*/
- settextjustify(300,300);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
- outtextxy(270,250,"SUN");
- setcolor(MAGENTA);
- setfillstyle(SOLID_FILL,MAGENTA);
- circle(170,370,25);
- floodfill(170,370,MAGENTA);
- }
- struct address
- {
- long long int housenum,phonenum,pin;
- char houseadd[100],name[50];
- };
- void address_book()//start of address book program
- {
- address addres[address_count];//declaring array of addres for more than 1 person to input
- int gdriver=DETECT,gmode; //INITIALSISING GRAPHICS
- initgraph(&gdriver,&gmode,"C://TC//bgi");//INITIALISING GRAPHICS
- setbkcolor(BLACK);//BACKGROUND COLOR
- setcolor(YELLOW);//SETTING COLOR FOR RECTANGLE
- rectangle(1,1,170,50); //RECTANGULAR COLUMN FOR INPUT
- setfillstyle(YELLOW,SOLID_FILL); //FILLING THE RECTANGLE
- gotoxy(2,2);
- cout<<"-------INPUT-------";
- cout<<"\n"<<"\n"<<"\n";
- for(int i=0;i<address_count;i++)//input
- {
- cout<<"enetr the name :";
- gets(addres[i].name);
- cout<<"enter the phone num :";
- cin>>addres[i].phonenum;
- cout<<"enter the house address (max 100 char) :";
- gets(addres[i].houseadd);
- cout<<"enter the pin code :";
- cin>>addres[i].pin; //pin
- cout<<"enetr the house number :";
- cin>>addres[i].housenum;
- cout<<endl;
- }
- cout<<endl;
- /* setcolor(YELLOW);//SETTING COLOR FOR RECTANGLE
- rectangle(1,300,400,50); //RECTANGULAR COLUMN FOR INPUT
- setfillstyle(YELLOW,SOLID_FILL); //FILLING THE RECTANGLE
- */
- cout<<"---------------OUTPUT----------------"<<endl;
- // cout<<"-------------"<<"***********************"<<"-------"<<endl;
- for( i=0;i<address_count;i++)
- {
- cout<<"name:"<<addres[i].name<<endl;
- cout<<"phone no."<<addres[i].phonenum<<endl;
- cout<<"address :"<<addres[i].houseadd<<endl;
- cout<<"pin code:"<<addres[i].pin<<endl;
- cout<<"house numb:"<<addres[i].housenum<<endl;
- cout<<endl;
- }
- }
- void calc()
- {
- clrscr();
- menu();
- cin >> ch;
- if (ch == 1)
- {
- c = mul(a, b);
- cout << "the multilication result is" << c;
- }
- else if (ch == 2)
- {
- c = add(a, b);
- cout << "the result is" << c;
- }
- else if (ch == 3)
- {
- c = sub(a, b);
- cout << "the result is" << c;
- }
- else if (ch == 4)
- {
- c = div(a, b);
- cout << "the result is " << c;
- }
- else if (ch == 5)
- {
- cout << "the power is";
- c = ramp(a, b);
- cout << "the result is" << c;
- }
- else if (ch == 6)
- {
- cout << "the modulus o9f the no. is" << endl;
- c = modulus(a);
- cout << c;
- }
- else if (ch == 7)
- {
- cout << "the cos value is" << endl;
- c = cores(a);
- cout << c;
- }
- else if (ch == 8)
- {
- cout << "the sin value is" << endl;
- c = res(a);
- cout << c;
- }
- else
- {
- cout << "out of credentials you asre a piece of shit";
- }
- getch();
- }
- float mul(float x, float y)
- {
- float res;
- res = x*y;
- return (res);
- }
- float add(float x, float y)
- {
- float res;
- res = x + y;
- return (res);
- }
- float sub(float x, float y)
- {
- float res;
- res = x - y;
- return (res);
- }
- float div(float x, float y)
- {
- float res;
- res = x / y;
- return (res);
- }
- float ramp(float x, float y)
- {
- float i, s = 1;
- for (i = 1; i <= y; i++)
- {
- s = s*x;
- }
- return (s);
- }
- double modulus(double x)
- {
- double res;
- res = fabs(x);
- return (res);
- }
- void menu()
- {
- cout << "=======PROGRAM FOR SCIENTIFIC CALCULATOR=======" << endl;
- cout << "enter the variabes" << endl;
- cout << "eneter a:" << endl;
- cout << "enter b:" << endl;
- cin >> a;
- cin >> b;
- cout << "enter the function which you want to perform" << endl;
- cout << "1.mult" << endl << "2.add" << endl << "3.sub" << endl << "4.div" << endl << "5.pow" << endl << "6.modulus" << endl;
- cout << "7.cos" << endl << "8.sin" << endl << "9.tan" << endl;
- }
- double cores(double ang)
- {
- double result = 0;
- if (ang == 45)
- {
- a = b = 1;
- c = a*a + b*b;
- cout << "the cos value of 45 deg is" << endl;
- result = (b / sqrt(c));
- }
- else if (ang == 60)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- cout << "the cos value is" << result;
- }
- else if (ang == 30)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- result = (sqrt(a) / c);
- }
- else if (ang == 90)
- {
- result = 1;
- cout << "cos value is ";
- }
- else if (ang == 37)
- {
- a = 3, b = 4;
- c = ((a*a) + (b*b));
- result = b / sqrt(c);
- cout << "the cos value of 37 is ";
- }
- else if (ang == 53)
- {
- a = 4, b = 3;
- c = ((a*a) + (b*b));
- result = a / sqrt(c);
- cout << "the cos value of 53 is ";
- }
- else if (ang == 0)
- {
- result == 1;
- cout << "the cos value is";
- }
- else
- {
- cout << "sorry out of the given credentials";
- }
- //getch();
- return (result);
- }
- double res(double ang)
- {
- double result = 0;
- if (ang == 45)
- {
- a = b = 1;
- c = a*a + b*b;
- cout << "the cos value of 45 deg is" << endl;
- result = (b / sqrt(c));
- cout << result;
- }
- else if (ang == 60)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- result = (sqrt(a) / c);
- cout << "\n" << "the sin value is" << result;
- }
- else if (ang == 30)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- result = (b / c);
- cout << "\n" << "the sin value is" << result;
- }
- else if (ang == 90)
- {
- result = 0;
- cout << "\n" << "the value of sin wll be" << result;
- }
- else if (ang == 37)
- {
- a = 3, b = 4;
- c = ((a*a) + (b*b));
- result = a / sqrt(c);
- cout << "\n" << "the sin value of 37 is" << result;
- }
- else if (ang == 53)
- {
- a = 4, b = 3;
- c = ((a*a) + (b*b));
- result = b / sqrt(c);
- cout << "\n" << "the sin value of 53 is" << result;
- }
- else if (ang == 0)
- {
- result == 0;
- cout << "\n" << "the sin value is " << result;
- }
- else
- {
- cout << "sorry out of the given credentials";
- }
- //getch();
- return (result);
- }
- void numbers_to_words()
- {
- cout<<"enter the five digits ";
- cout<<"\n";
- cin>>n5>>n4>>n1>>n2>>n3;
- switch(n5%10000)
- {
- case 0:break;
- case 1: cout<<" ten";break;
- case 2:cout<<" tewnty";break;
- case 3:cout<<" thirty";break;
- case 4:cout<<" forty";break;
- case 5:cout<<" fifty";break;
- case 6:cout<<" sixty";break;
- case 7:cout<<" seventy";break;
- case 8:cout<<" eighty";break;
- case 9:cout<<" ninety";break;
- default:cout<<" ERROR 404";break;
- }
- switch(n4%1000)
- {
- case 0:cout<<" thousand";break;
- case 1:cout<<"one thousand";
- break;
- case 2: cout<<"two thousand";break;
- case 3: cout<<"three thousand";break;
- case 4: cout<<"four thousand";break;
- case 5:cout<<"five thousand ";break;
- case 6 : cout<<"six thousand ";break;
- case 7:cout<<"seven thousand ";break;
- case 8: cout<<"eight thousand";break;
- case 9:cout<<"nine thousand";break;
- default:cout<<"error 404"; break;
- }
- switch(n1%100)
- {
- case 0:break;
- case 1:cout<<" one hundred and ";
- break;
- case 2: cout<<" two hundred and ";break;
- case 3: cout<<" three hundred and";break;
- case 4: cout<<" four hundred and ";break;
- case 5:cout<<" five hundred and ";break;
- case 6 : cout<<" six hundred and ";break;
- case 7:cout<<" seven hundred and ";break;
- case 8: cout<<" eight hundred and ";break;
- case 9:cout<<" nine hunderd and ";break;
- default:cout<<" error 404"; break;
- }
- switch(n2%10)
- {
- case 0:break;
- case 1: cout<<" ten";break;
- case 2:cout<<" tewnty";break;
- case 3:cout<<" thirty";break;
- case 4:cout<<" forty";break;
- case 5:cout<<" fifty";break;
- case 6:cout<<" sixty";break;
- case 7:cout<<" seventy";break;
- case 8:cout<<" eighty";break;
- case 9:cout<<" ninety";break;
- default:cout<<" ERROR 404";break;
- }
- switch(n3%10)
- {
- case 0: break;
- case 1: cout<<" one";break;
- case 2:cout<<" two";break;
- case 3:cout<<" three";break;
- case 4:cout<<" four";break;
- case 5:cout<<" five";break;
- case 6:cout<<" six";break;
- case 7:cout<<" seven";break;
- case 8:cout<<" eight";break;
- case 9:cout<<" nine ";break;
- default:cout<<" ERROR 404";break;
- }
- }
- void smiley()
- {
- for(int i=1;i<=360;i++) //start of loop
- {
- arc(400,250,0,i,210);//THE FACE MAIN PART
- setcolor(CYAN);
- ellipse(300,200,0,i,100,40);
- circle(300,200,30);//THE FIRST EYE
- ellipse(500,200,0,i,100,40);//THE SECOND EYE ELLIPSE 2
- setcolor(CYAN);
- setcolor(CYAN);
- circle(500,200,30);//THE SECOND EYE
- arc(400,300,180,360,100); //THE MOUTH
- delay(10);
- } //end of loop
- }//end of main
- void moving_bus()
- {
- setcolor(GREEN);
- for(int i=1;i<200;i++)
- {
- line(100,220,700,220);
- circle(150+i,200,20); //back tyre
- circle(150+i,200,15);//rim of back tyre
- circle(350+i,200,20);//front tyre
- circle(350+i,200,15);//rim of front tyre
- delay(10);
- cleardevice();
- //line(100+i,100+i,50,50);
- rectangle(100+i,100,400+i,200); //main body
- rectangle(105+i,105,300+i,150);//back window
- rectangle(305+i,105,385+i,150);//front window
- line(185+i,105,185+i,200);//back part of door
- line(265+i,105,265+i,200);//front part of door
- rectangle(195+i,160,205+i,165);//door handle
- rectangle(390+i,175,400+i,185); //front indicator
- settextjustify(100,220);
- settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
- outtextxy(100,220,"Moving bus");
- settextjustify(130,260);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
- outtextxy(130,260,"by RAM");
- delay(10);
- //cleardevice();
- }//end of loop
- }//end of function
- void moving_train()//start of train function
- {
- setcolor(GREEN);
- for(int i=1;i<200;i++)
- {
- rectangle(40,220,700,230); //the base of the train(track)
- /*the tyre part with spokes and rims---------*/
- circle(150+i,200,20); //back tyre
- circle(150+i,200,15);//rim of back tyre
- circle(195+i,200,20);//2nd back tyre
- circle(195+i,200,15);//rim of 2nd back tyre right hand side
- rectangle(150+i,196,200+i,207);//spoke between 2 back tryes
- circle(195+i,200,20);//2nd back tyre(right from left)
- circle(350+i,200,20);//front 2nd tyre(right most)
- rectangle(305+i,196,355+i,207);//spoke between 2 front tryes
- circle(305+i,200,15);//rim of front 1st trye right ahnd side
- circle(305+i,200,20);//front 1st trye
- circle(350+i,200,15);//rim of 2nd front tyre
- /*---now for the holding pivot or the attachment of the spoke to the train--*/
- rectangle(150+i,180,155+i,200);//pivot of the 1 st tyre (back)
- rectangle(195+i,180,200+i,200);//pivot of the 2nd BACK TYRE
- rectangle(305+i,180,310+i,200);//pivot of 2nd front tyre (2nd form rightmost)
- rectangle(350+i,180,355+i,200);//pivot of 1st front tyre (1st from rightmost)
- /*=========now for the upper part of the train===*/
- rectangle(280+i,90,360+i,100);//front (rightmost)
- rectangle(120+i,90,200+i,100);//backside
- /*======electricity connection wire =====*/
- line(40,50,500,50);//main line(upper wire)
- line(300+i,70,320+i,50);//connector(2) (train with main line)(1st one from right)
- line(300+i,70,310+i,90);//small bending in the 1st connector
- line(150+i,70,160+i,50);//small bending in connector (1)
- line(150+i,70,160+i,90);//connector(1)
- delay(10);
- cleardevice();
- /*main body of the train(engine)*/
- rectangle(100+i,100,400+i,200); //main body
- rectangle(105+i,105,300+i,150);//back window
- rectangle(305+i,105,385+i,150);//front window
- line(185+i,105,185+i,200);//back part of door
- line(265+i,105,265+i,200);//front part of door
- rectangle(195+i,160,205+i,165);//door handle
- rectangle(390+i,175,400+i,185); //front indicator
- /*main body of the wagon*/
- rectangle(1+i,150,90+i,200);
- line(1+i,150,90+i,100);
- line(90+i,100,90+i,150);
- circle(20+i,200,20);//trye of the small wagon back one
- circle(20+i,200,15);//rim of the back one
- circle(70+i,200,20);
- circle(70+i,200,15);
- rectangle(90+i,180,99+i,200); //the connection between the engine and the wagon
- settextjustify(100,240);
- settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
- outtextxy(100,240,"Moving train");
- settextjustify(130,280);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
- outtextxy(130,280,"by RAM");
- delay(10);
- } //end of loop
- getch();
- closegraph();
- }//end of function
- THE OUTPUT
- This video is upto only 0:56 not 2:01
- an error occured during the process thats why please cooperate
Advertisement
Add Comment
Please, Sign In to add comment