/*
The Rooter
One day, my eyes stuck on Program No.13 of the program sheet teacher had given me
I started developing it and saw that, it would be fun to make it more sophisticated
I incorporated some of the things in this program that I wanted to do for a long time
First of all, The credit screen has ASCII art which I love very much and I am looking for a way to include ANSI too
The menu and the input screen makes use of "SetConsoleCursorPosition" in windows.h to make it appear centered
The credit screen music is accessed and played with the help of mmsystem.h
Overall this program offers pretty much nothing that can be considered as significant
I think I have wasted a lot of time which could be used for doing something useful...
Compile this Borland C Compiler
-Aswin Babu K (aswinbabuk@gmail.com)
*/
#include
#include
#include
#include
#include
#include
#include
#include
char opt;
int flag;
int a, b, c;
float root, r1, r2;
void menu();
void credit();
void quad();
void linear();
void cursor(short, short);
void cursor (short x, short y)
{
COORD coord = {x, y};
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), coord);
}
void main()
{
credit();
menu();
}
void menu()
{
start:
clrscr();
cursor (15, 8); //Top Border
textbackground (LIGHTBLUE);
cprintf (" ");
cursor (15, 15); //Bottom border
cprintf (" ");
for (int i=9; i<15; ++i)
{
cursor (15, i);
cprintf (" ");
}
for (int i=9; i<15; ++i)
{
cursor (63, i);
cprintf (" ");
}
textbackground (BLACK);
textcolor (YELLOW);
cursor (16, 9);
cprintf ("What do you want to do?"); //The real menu items start here
cursor (16, 10);
cprintf ("1] Solve a linear equation");
cursor (16, 11);
cprintf ("2] Solve a quadratic equation");
cursor (16, 12);
cprintf ("3] Credits");
cursor (16, 13);
cprintf ("4] Exit");
cursor (16, 14);
cprintf ("Enter a choice (1-4): "); //The real menu items end here
cin>>opt;
if (opt=='1')
{
linear();
}
if (opt=='2')
{
quad();
}
if (opt=='3')
{
flag=1;
credit();
}
if (opt=='4')
{
exit(0);
}
else
{
clrscr();
cursor (32, 12);
cprintf ("Invalid Option!");
getch();
goto start;
}
}
void credit()
{
clrscr();
textcolor (BLACK + BLINK);
cprintf ("Version: 0.5.8 [Build: SA2801121815] ");
cursor (0, 4);
textcolor (LIGHTGREEN);
cprintf (" ,`""',");
cout<
cprintf (" ;' ` ;");
cout<
cprintf (" ;`,',;");
cout<
cprintf (" ;' ` ;");
textcolor (LIGHTRED);
cprintf (" @@@@@@@ @@@ @@@ @@@@@@@@");
cout<
textcolor (LIGHTGREEN);
cprintf (" ,,, ;`,',;");
textcolor (LIGHTRED);
cprintf (" @@! @@! @@@ @@! ");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;,` ; ;' ` ; ,',");
textcolor (LIGHTRED);
cprintf (" @!! @!@!@!@! @!!!:! ");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;`,'; ;`,',; ;,' ;");
textcolor (LIGHTRED);
cprintf (" !!: !!: !!! !!: ");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;',`; ;` ' ; ;`'`';");
textcolor (LIGHTRED);
cprintf (" : : : : : :: :::");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;` '',''` `,',`',;");
cout<
textcolor (LIGHTGREEN);
cprintf (" `''`'; ', ;`'`'");
textcolor (LIGHTRED);
cprintf (" @@@@@@@ @@@@@@ @@@@@@ @@@@@@@ @@@@@@@@ @@@@@@@");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;' `';");
textcolor (LIGHTRED);
cprintf (" @@! @@@ @@! @@@ @@! @@@ @@! @@! @@! @@@");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;` ' ;");
textcolor (LIGHTRED);
cprintf (" @!@!!@! @!@ !@! @!@ !@! @!! @!!!:! @!@!!@!");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;' `';");
textcolor (LIGHTRED);
cprintf (" !!: :!! !!: !!! !!: !!! !!: !!: !!: :!!");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;` ' ;");
textcolor (LIGHTRED);
cprintf (" : : : : :. : : :. : : : :: ::: : : :");
cout<
textcolor (LIGHTGREEN);
cprintf (" ; ',';");
cout<
textcolor (LIGHTGREEN);
cprintf (" ;,' ';");
cout<
textcolor (LIGHTGREEN);
cprintf (" \|/\|/;\|/");
if (flag==1)
{
mciSendString ("play c:\\Windows\\Media\\Flourish.MID",NULL,0,NULL);
}
getch();
if (flag==1)
{
mciSendString ("Stop c:\\Windows\\Media\\Flourish.MID",NULL,0,NULL);
}
menu();
}
void linear()
{
clrscr();
textbackground (BLACK);
cursor (14, 12);
textcolor (YELLOW);
cprintf ("This functionality has not yet been implimented :(");
getch();
menu();
}
void quad()
{
clrscr();
cursor (15, 9); //Top Border
textbackground (LIGHTBLUE);
cprintf (" ");
for (int i=9; i<14; ++i)
{
cursor (15, i);
cprintf (" ");
}
for (int i=9; i<14; ++i)
{
cursor (63, i);
cprintf (" ");
}
cursor (15, 14); //Bottom border
textbackground (LIGHTBLUE);
cprintf (" ");
textbackground (BLACK);
cursor (30, 10);
cprintf ("Ax^2 + Bx + C = 0");
cursor (16, 11);
cprintf ("A:");
cursor (16, 12);
cprintf ("B:");
cursor (16, 13);
cprintf ("C:");
cursor (19, 11);
cin>>a; //input a
cursor (30, 10);
cprintf ("%d", a); //display a
cursor (19, 11);
cprintf ("%d", a);
cursor (19, 12);
cin>>b; //input b
cursor (37, 10);
cprintf ("%d", b); //display b
cursor (19, 12);
cprintf ("%d", b);
cursor (19, 13);
cin>>c; //input c
cursor (42, 10);
cprintf ("%d", c); //display c
cursor (19, 13);
cprintf ("%d", c);
root=sqrt(((b*b)-4)*a*c)/(2*a);
clrscr();
r1=(-b/2*a)+root;
r2=(-b/2*a)-root;
cursor (23, 12);
cprintf ("Roots are: %f", r1);
cprintf (" and %f", r2);
getch();
menu();
}
No comments:
Post a Comment