Skip to content

Instantly share code, notes, and snippets.

@handstandsam
Created August 30, 2017 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save handstandsam/47b514cc8ba4884630666de696dd2057 to your computer and use it in GitHub Desktop.
Save handstandsam/47b514cc8ba4884630666de696dd2057 to your computer and use it in GitHub Desktop.
Sam Edwards - High School Junior Expo Project - Year 2000
//Sam Edwards
//expo.cpp
//Include statements
#include<iomanip.h>
#include<iostream.h>
#include<math.h>
#include<string.h>
#include<process.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<graphics.h>
//declaration of all functions
void graphicintro();
void welcome();
void quadratic(double &quadans, double &quadans2);
void quadraticanswers(double &quadans, double &quadans2);
void distance(double &distans);
void distanceanswer(double &distans);
void pythagoreanswitch(int pyswitch);
void pythagorean();
void pythagoreanab();
void quit();
void clrscr(void);
int gamescore=0;
void bienviendidos(/*char &llama*/);
void fun1(int &gamescore);
void fun2(int &gamescore);
void fun3(int &gamescore);
void fun4(int &gamescore);
void fun5(int &gamescore);
void fun6(int &gamescore);
void fun7(int &gamescore);
void finalscore(int &gamescore/* char &llama*/);
void expo();
void espanol(/*int &gamescore*/);
void runmain();
void welcomefirst();
//void comotellamas(char &llama);
//Main Fuction which is the basis for all other functions
int main()
{
// char[40] llama;
welcomefirst();
return 0;
}
void welcomefirst()
{
gotoxy(45,13);
cout<<setw(60)<<"Welcome To Sam Edwards C++ Program For Expo 2000.";
runmain();
}
void runmain()
{
clrscr();
int whichone;
cout<<setw(60)<<"Which Subject Would You Like To Use.\n";
cout<<"1.Math/Physics\n2.Espanol\n";
cin>>whichone;
if (whichone==1)
{expo();}
else if (whichone==2)
{espanol(/*gamescore*/);}
else
{runmain();}
}
void expo()
{
//initializing graphics drivers
int gdriver=DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode,"");
//declaring variables quadans, quadans2.
double quadans, quadans2;
//Setting Text Background to black
textbackground(BLACK);
//Calling the Graphical Intro Function
graphicintro();
//Calling the welcome function which gives main menu
welcome();
//ClearScreen Function
clrscr();
//Quit Function
quit();
}
//intro graphic is created
void graphicintro()
{
//Graphic Foreground Set To Blue
setcolor(BLUE);
//Graphic Background Set To Black
setbkcolor(BLACK);
//Clear Graphics Screen
cleardevice();
//Set Text Color To White
textcolor(WHITE);
//placing text in center of screen
gotoxy (10,15);
{cout<<setw(44)<<"WELCOME TO SAM EDWARDS'\n"<<setw(56)
<<"MATH AND PHYSICS EQUATION SOLVER";}
//Creating Circles
circle(320,240,175);
circle(160,81,50);
circle(480,81,50);
circle(160,398,50);
circle(480,398,50);
//Pausing the screen
delay(3500);
//Closing the graphic section
closegraph();
}
//Main Menu Function
void welcome()
{
//Declaring Variables
int selection, pyswitch;
double distans, quadans, quadans2;
//Clearscreen Function
clrscr();
//Display Text Header
cout<<setw(45)<<"*************\n";
cout<<setw(45)<<"| Equations |\n";
cout<<setw(45)<<"*************\n";
//Display Options
cout<<"1. Quadratic Formula\n";
cout<<"2. Distance Equation\n";
cout<<"3. Pythagorean Therom\n"<<endl;
cout<<endl;
cout<<setw(57)<<"Please Enter Your Equation Selection: ";
//Recieve user imput from keyboard
cin>>selection;
//Sending user to selected Equation Function
if (selection==1)
{quadratic(quadans, quadans2);}
else if (selection==2)
{distance(distans);}
else if (selection==3)
{pythagoreanswitch(pyswitch);}
//Setting 11 as Programmer designed escape variable
else if (selection==11)
{exit(1);}
else
{cout<<"An Error Has Occured";
welcome();}
}
//Quadratic Equation Function
void quadratic(double &quadans, double &quadans2)
{
//Declaring Variables for this function
int quada, quadb, quadc;
double insidesqrt;
//ClearScreen Function
clrscr();
//Getting Quadratic Variables
cout<<"Quadratic Formula: x=(-b +- sqrt(b^2-4ac))/2a\n"<<endl;
cout<<"Enter the value of a\n";
cin>>quada;
cout<<"Enter the value of b\n";
cin>>quadb;
cout<<"Enter the value of c\n";
cin>>quadc;
//Solving for the equation
insidesqrt=(quadb*quadb)-(4*quada*quadc);
//error handling for square roots of negative numbers
if (insidesqrt<0)
{
gotoxy(35,13);
cout<<"No Solution";
getch();
quadratic(quadans, quadans2);
}
//puts both answers into variables
quadans=(((-quadb)+sqrt(insidesqrt))/(2*quada));
quadans2=(((-quadb)-sqrt(insidesqrt))/(2*quada));
//Starts function quadraticanswers().
quadraticanswers(quadans, quadans2);
}
//Answers To The Quadratic Equation
void quadraticanswers(double &quadans, double &quadans2)
{
//Displays final answers to the final equation
cout<<endl;
cout<<setw(30)<<"x= "<<quadans<<", "<<quadans2<<endl;
getch();
}
//Solving Distance Equations with Time, and other varibles
void distance(double &distans)
{
//declaring variables
double initvel, grav, time, ans;
//ClearScreen
clrscr();
//Getting Data from user
cout<<setw(65)<<"Distance=(Initial Velocity)*time-.5*Gravity*(Time^2)\n"<<endl;
cout<<"Please Enter The Initial Vertical Velocity: ";
cin>>initvel;
cout<<endl;
cout<<"Please Enter The Force Of Gravity(-9.8m/s on earth): ";
cin>>grav;
cout<<endl;
cout<<"Please Enter Amount of Time in Seconds: ";
cin>>time;
cout<<endl;
//Calculating distance equation answer
distans=initvel*time-.5*grav*(time*time);
//Run's distanceanswer function
distanceanswer(distans);
}
//Fuction that displays answer to distance equation
void distanceanswer(double &distans)
{
cout<<"The Distance Was "<<distans<<" Meters.\n"<<endl;
getch();
clrscr();
quit();
}
//Finds out which pythagorean variable they wish to solve for.
void pythagoreanswitch(int pyswitch)
{
clrscr();
cout<<"Would you like to solve for\n 1.(C)\n 2.(A or B)\n";
cin>>pyswitch;
if (pyswitch==1)
{pythagorean();}
else if (pyswitch==2)
{pythagoreanab();}
}
//This is the function if they want to solve for C
void pythagorean()
{
double pya, pyb, pyans;
clrscr();
cout<<setw(50)<<"What Are the values for A & B";
cout<<setw(73)<<"A^2+B^2=C^2\n";
cout<<endl;
cout<<"Enter the value of A\n";
cin>>pya;
cout<<"Enter the value of B\n";
cin>>pyb;
pyans=sqrt((pya*pya)+(pyb*pyb));
cout<<"The Answer is "<<pyans;
getch();
clrscr();
quit();
}
//finds answers for a or b variable
void pythagoreanab()
{
double pya2, pyc2, pyans2;
clrscr();
cout<<setw(50)<<"What Are the values for (A or B) & C";
cout<<setw(73)<<"A^2+B^2=C^2\n";
cout<<endl;
//getting user data
cout<<"Enter the value of (A or B)\n";
cin>>pya2;
cout<<"Enter the value of C\n";
cin>>pyc2;
//finding answer
pyans2=sqrt((pyc2*pyc2)-(pya2*pya2));
//displaying answer
cout<<"The Answer is "<<pyans2;
getch();
clrscr();
quit();
}
//Exit Y/N function
void quit()
{
//declares liketoexit variable
//User can terminate program, or use it again.
char liketoexit;
cout<<"Would You Like To Quit\n";
cout<<"y=YES, n=NO"<<endl;
cin>>liketoexit;
//if statement for quitting the program(exiting)
if (liketoexit=='y')
{exit(1);}
else if (liketoexit=='n')
{runmain();}
else
{exit(1);}
}
//main fuction for Spanish trivia game
void espanol(/*char &llama*/)
{
// char temp[40];
// cin>>temp;
// cin.get(temp,40);
// cin.ignore(80,'\n');
// cout<<endl<<"hello"<<temp;
// getch();
clrscr();
textcolor(YELLOW);
//runs bienveindidos(welcome) function
bienviendidos();
clrscr();
}
//bienviendidos Function that welcomes player to the game
void bienviendidos(/*char &llama*/)
{
clrscr();
gotoxy(10,13);
//displays message
cout<<setw(57)<<"Hola Y Bienviendidos al Juego De Espanol. ";
getch();
fun1(gamescore);
// comotellamas(llama);
}
//Records the Players name
/*void comotellamas(char &llama)
{
clrscr();
cout<<"Como Te Llamas?\n"<<endl;
cin>>llama;
cin.get(llama,40);
cin.ignore(80,'\n');
//sends to the first question function
fun1(gamescore);
}*/
//function for the first equation
void fun1(int &gamescore)
{
//PREGUNTA=QUESTION
clrscr();
int pregunta1;
//What is the Capital of Spain?
cout<<"Cual es la capital de Espana? (Pregunta 1)\n"<<endl;
cout<<"1.Madrid\n2.Barcelona\n3.Bilbao\n4.Seville"<<endl<<endl;
cout<<"Answer = ";
cin>>pregunta1;
gotoxy(34,13);
//Checks if the answer is correcto
if (pregunta1==1)
{cout<<"CORRECTO!";
gamescore=gamescore+1;}
else if (pregunta1==2)
{cout<<"INCORRECTO!";}
else if (pregunta1==3)
{cout<<"INCORRECTO!";}
else if (pregunta1==4)
{cout<<"INCORRECTO!";}
//error handling
else
{cout<<"An Error Has Occured";
fun1(gamescore);}
//Waits for keystroke
getch();
//sends to second pregunta
fun2(gamescore);
}
//Second Pregunta Function
void fun2(int &gamescore)
{
clrscr();
int pregunta2;
//What is the name of the islands of Spain that are close to africa?
cout<<setw(50)<<"Como se llaman las islas de Espana que estan cerca de Africa? (Pregunta 2)\n"<<endl;
cout<<"1.Bahamas\n2.United Kingdom\n3.Las Islas Canarias\n4.Las Islas De Espana\n"<<endl;
cout<<"Answer = ";
cin>>pregunta2;
//outputs the correcto or incorrecto at specified coordinates
gotoxy(34,13);
//checks if answer is correct
if (pregunta2==1)
{cout<<"INCORRECTO!";}
else if (pregunta2==2)
{cout<<"INCORRECTO!";}
else if (pregunta2==3)
{cout<<"CORRECTO!";
gamescore=gamescore+1;}
else if (pregunta2==4)
{cout<<"INCORRECTO!";}
else
{cout<<"An Error Has Occured";
fun2(gamescore);}
getch();
//sends to question 3
fun3(gamescore);
}
//question 3 function
void fun3(int &gamescore)
{
clrscr();
int pregunta3;
//Where were the 1992 Olympic Games Celebrated (held)?
cout<<"Donde se celebraron Los Juegos Olympicos En 1992? (Pregunta 3)\n"<<endl;
cout<<"1.Madrid\n2.Tegucigalpa\n3.Los Estados Unidos\n4.Barcelona\n";
cout<<endl;
cout<<"Answer = ";
cin>>pregunta3;
gotoxy(34,13);
//checks if answer is correct
if (pregunta3==1)
{cout<<"INCORRECTO!";}
else if (pregunta3==2)
{cout<<"INCORRECTO!";}
else if (pregunta3==3)
{cout<<"INCORRECTO!";}
else if (pregunta3==4)
{cout<<"CORRECTO!";
gamescore=gamescore+1;}
else
{cout<<"An Error Has Occured";
fun3(gamescore);}
getch();
//sends to question 4
fun4(gamescore);
}
//pregunta 4 function
void fun4(int &gamescore)
{
clrscr();
int pregunta4;
//What separates Spain and Africa?
cout<<"Que Separa Espana y Africa? (Pregunta 4)\n"<<endl;
cout<<"1.Portugal\n2.Italia\n3.El Estrecho de Gibraltar\n4.Egypt\n";
cout<<endl;
cout<<"Answer = ";
cin>>pregunta4;
gotoxy(34,13);
//checks to see if imput is correct answer
if (pregunta4==1)
{cout<<"INCORRECTO!";}
else if (pregunta4==2)
{cout<<"INCORRECTO!";}
else if (pregunta4==3)
{cout<<"CORRECTO!";
gamescore=gamescore+1;}
else if (pregunta4==4)
{cout<<"INCORRECTO!";}
else
{cout<<"An Error Has Occured";
fun4(gamescore);}
getch();
//goes to the next question, #5
fun5(gamescore);
}
//question 5 fuction
void fun5(int &gamescore)
{
clrscr();
int pregunta5;
//What is the name of the mountains in Spain?
cout<<"Como se llaman las montanas en Espana? (Pregunta 5)\n"<<endl;
cout<<"1.Alpes\n2.Pirineos\n3.Andes\n4.Himalayas\n";
cout<<endl;
cout<<"Answer = ";
cin>>pregunta5;
gotoxy(34,13);
//checks to see if imput is the correct answer
if (pregunta5==1)
{cout<<"INCORRECTO!";}
else if (pregunta5==2)
{cout<<"CORRECTO!";
gamescore=gamescore+1;}
else if (pregunta5==3)
{cout<<"INCORRECTO!";}
else if (pregunta5==4)
{cout<<"INCORRECTO!";}
else
{cout<<"An Error Has Occured";
fun5(gamescore);}
getch();
//goes to question 6
fun6(gamescore);
}
//question 6 function
void fun6(int &gamescore)
{
clrscr();
int pregunta6;
//What is the name of the Sea north of Spain?
cout<<"Como se llaman El Mar Al Norte De Espana? (Pregunta 6)\n"<<endl;
cout<<"1.Cantabrico\n2.Mediterraneo\n3.Oceano Atlantico\n4.Oceano Pacifico\n";
cout<<endl;
cout<<"Answer = ";
cin>>pregunta6;
gotoxy(34,13);
//checks the answer
if (pregunta6==1)
{cout<<"CORRECTO!";
gamescore=gamescore+1;}
else if (pregunta6==2)
{cout<<"INCORRECTO!";}
else if (pregunta6==3)
{cout<<"INCORRECTO!";}
else if (pregunta6==4)
{cout<<"INCORRECTO!";}
else
{cout<<"An Error Has Occured";
fun6(gamescore);}
getch();
//runs the last question
fun7(gamescore);
}
//Last Question, BOGUS question, I AM THE BEST!!!!!!!!!
void fun7(int &gamescore)
{
clrscr();
int pregunta7;
//Who is the Best Person?
cout<<"Quien Es El Mejor Persona? (Pregunta 7)\n"<<endl;
cout<<"1.Sam Edwards\n2.YOURSELF(Whoever is playing the game now)\n3.George W. Bush\n4.Bill Clinton\n";
cout<<endl;
cout<<"Answer = ";
cin>>pregunta7;
gotoxy(34,13);
//Checks and sees if I am the best person, which i most definitely am.
if (pregunta7==1)
{cout<<"CORRECTO!";
gamescore=gamescore+1;}
else if (pregunta7==2)
{cout<<"INCORRECTO!";}
else if (pregunta7==3)
{cout<<"INCORRECTO!";}
else if (pregunta7==4)
{cout<<"INCORRECTO!";}
else
{cout<<"An Error Has Occured";
fun6(gamescore);}
getch();
//runs the program which outputs score of user
finalscore(gamescore /*,llama*/);
}
//JUDGEMENT QUESTION, WERE YOU GOOD ENOUGH?
void finalscore(int &gamescore /*,char &llama*/)
{
clrscr();
gotoxy(29,13);
//Your final score is:
cout<</*llama<<*/", Su Tanto Final es "<<gamescore<<"/7"<<endl;
if (gamescore==0)
//You don't speat spanish
cout<<setw(60)<<"TU NO HABLES ESPANOL";
else if (gamescore==1)
//Loser
cout<<setw(60)<<"PERDEDOR";
else if (gamescore==2)
//How Bad.
cout<<setw(60)<<"QUE MAL";
else if (gamescore==3)
//You're OK.
cout<<setw(60)<<"TU ERES MAS O MENOS BIEN";
else if (gamescore==4)
//Good Job.
cout<<setw(60)<<"BUEN TRABAJO SENOR(ITA)";
else if (gamescore==5)
cout<<setw(60)<<"BUEN TRABAJO SENOR(ITA)";
else if (gamescore==6)
//You're close to being the best person in the world
cout<<setw(60)<<"TU ESTAS CERCA DE LA MEJOR PERSONA DEL MUNDO";
else if (gamescore==7)
//you are the best person in the world
cout<<setw(60)<<"TU ERES LA MEJOR PERSONA DEL MUNDO";
getch();
closegraph();
clrscr();
//runs the quit function
quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment