CODE
# include <stdio.h>
# include <conio.h>
int choice,air1,air2;
void rus(void);
void usa(void);
void mig29(void);
void mig31(void);
void su27(void);
void su25(void);
void su24(void);
void pakfa(void);
void tu95(void);
void tu22m(void);
void tu160(void);
void f16(void);
void f15(void);
void a10(void);
void f35(void);
void f22(void);
void b1(void);
void b2(void);
void b52(void);
void main()
{
clrscr();
clrscr();
gotoxy(2,2);
cprintf("Press a hotkey");
gotoxy(2,4);
cprintf("[1] Soviet/Russian aircraft");
gotoxy(2,5);
cprintf("[2] US aircraft");
gotoxy(2,6);
cprintf("[3] Quit");
gotoxy(2,8);
cprintf("Current selection: ");
scanf("%d",&choice);
switch(choice)
{
case 1: clrscr();
rus();
break;
case 2: clrscr();
usa();
break;
case 3: gotoxy(2,10);
printf("Closing program, press any key to continue.");
break;
default: gotoxy(2,10);
printf ("Invalid key!");
break;
}
getch();
}
void rus(void)
{
int air1,choice;
clrscr();
gotoxy(2,2);
cprintf("Input the corresponding key to read the aircraft's information");
gotoxy(2,4);
cprintf("[1] MiG-29");
gotoxy(2,5);
cprintf("[2] Su-27");
gotoxy(2,6);
cprintf("[3] MiG-31");
gotoxy(2,7);
cprintf("[4] Su-24");
gotoxy(2,8);
cprintf("[5] Su-25");
gotoxy(2,9);
cprintf("[6] T-50 PAK-FA");
gotoxy(2,10);
cprintf("[7] Tu-22M");
gotoxy(2,11);
cprintf("[8] Tu-95");
gotoxy(2,12);
cprintf("[9] Tu-160");
gotoxy(2,13);
cprintf("[10] Back");
gotoxy(2,15);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
mig29();
break;
case 2: clrscr();
su27();
break;
case 3: clrscr();
mig31();
break;
case 4: clrscr();
su24();
break;
case 5: clrscr();
su25();
break;
case 6: clrscr();
pakfa();
break;
case 7: clrscr();
tu22m();
break;
case 8: clrscr();
tu95();
break;
case 9: clrscr();
tu160();
break;
case 10: clrscr();
rus();
break;
default: gotoxy(2,15);
printf ("Invalid key!");
break;
}
}
void usa(void)
{
int air2,choice;
clrscr();
gotoxy(2,2);
cprintf("Input the corresponding key to read the aircraft's information");
gotoxy(2,4);
cprintf("[1] F-16");
gotoxy(2,5);
cprintf("[2] F-15");
gotoxy(2,6);
cprintf("[3] A-10");
gotoxy(2,7);
cprintf("[4] F-35");
gotoxy(2,8);
cprintf("[5] F-22");
gotoxy(2,9);
cprintf("[6] B-1B");
gotoxy(2,10);
cprintf("[7] B-2");
gotoxy(2,11);
cprintf("[8] B-52");
gotoxy(2,12);
cprintf("[9] Back");
gotoxy(2,14);
cprintf("Current selection: ");
scanf("%d",&air2);
switch(choice)
{
case 1: clrscr();
f16();
break;
case 2: clrscr();
f15();
break;
case 3: clrscr();
a10();
break;
case 4: clrscr();
f35();
break;
case 5: clrscr();
f22();
break;
case 6: clrscr();
b1();
break;
case 7: clrscr();
b2();
break;
case 8: clrscr();
b52();
break;
case 9: clrscr();
usa();
break;
default: gotoxy(2,14);
printf ("Invalid key!");
break;
}
}
void mig29(void)
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("MiG-29 Fulcrum");
gotoxy(2,4);
cprintf("The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole");
gotoxy(2,5);
cprintf("fighter aircraft developed in the 1970s. It became a deadly adversary");
gotoxy(2,6);
cprintf("against its US counterparts, the F-16 and the F-15. It also saw service");
gotoxy(2,7);
cprintf("with other nations, and evolved into more sophiscated variants like the MiG-35.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&ret);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void su27(void)
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("Su-27 Flanker");
gotoxy(2,4);
cprintf("The Su-27, NATO codename Flanker is a Soviet fourth-generation air");
gotoxy(2,5);
cprintf("superiority jet fighter, designed as an answer to the newer US fighters");
gotoxy(2,6);
cprintf("alongside with the MiG-29. Equipped with sophisticated avionics and armament,");
gotoxy(2,7);
cprintf("it is a formidable adversary and has other advanced versions like the Su-35.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void mig31(void)
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("MiG-31 Foxhound");
gotoxy(2,4);
cprintf("The MiG-31 is basically an advanced version of the MiG-25 Foxbat");
gotoxy(2,5);
cprintf("interceptor aircraft. Although cannot fly as fast or as high like its");
gotoxy(2,6);
cprintf("cousin, it has better avionics and armament systems that can pose a potential");
gotoxy(2,7);
cprintf("threat to Western air forces.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void su24(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Su-24 Fencer");
gotoxy(2,4);
cprintf("A strike aircraft, utilizing variable-geometry wings similar");
gotoxy(2,5);
cprintf("to the F-111. Replacing the older Su-7, this all-weather aircraft,");
gotoxy(2,6);
cprintf("codenamed Fencer by NATO, its saw action in conflicts involving the USSR/");
gotoxy(2,7);
cprintf("Russia. It is scheduled to be replaced by the Su-34.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void su25(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Su-25 Frogfoot");
gotoxy(2,4);
cprintf("Nicknamed Grach by Russian forces, which is bird rook in the local tongue,");
gotoxy(2,5);
cprintf("the Su-25 is a close support aircraft, well-armored and armed similar to");
gotoxy(2,6);
cprintf("the A-10. It saw action in Afghanistan in the 1980s, Iran-Iraq War by Iraqi");
gotoxy(2,7);
cprintf("pilots, and other numerous conflicts.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void pakfa(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("T-50 PAK-FA");
gotoxy(2,4);
cprintf("Currently under development, the PAK-FA is Russia's next");
gotoxy(2,5);
cprintf("generation fighter aircraft, made as a successor to the MiG-29 and the");
gotoxy(2,6);
cprintf("Su-27. Resembling its American counterpart, the F-22, it is equipped with");
gotoxy(2,7);
cprintf("the latest systems, and it also has some stealth capablilities");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void tu95(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Tu-95 Bear");
gotoxy(2,4);
cprintf("Designed to reach American targets at long ranges, the Tu-95 is a 4-engined");
gotoxy(2,5);
cprintf("turboprop bomber.");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void tu22m(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Tu-22M Backfire");
gotoxy(2,4);
cprintf("Although not a derivative of the earlier Tu-22 Blinder supersonic bomber,");
gotoxy(2,5);
cprintf("the Tu-22M/26 Backfire is a swing-wing aircraft both capable of carrying missiles");
gotoxy(2,6);
cprintf("or standard bombs. In naval use, it represented a threat to NATO forces");
gotoxy(2,7);
cprintf("at sea as a result of its long-range anti-shippping strike role.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void tu160(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("Tu-160 Blackjack");
gotoxy(2,4);
cprintf("A massive supersonic heavy bomber, the Tu-160, nicknamed the White Swan");
gotoxy(2,5);
cprintf("Swan because of its anti-flash white color, first saw service in the Soviet Air");
gotoxy(2,6);
cprintf("Force in the late 1980s, but only did so officially in 2005. It is allegedly");
gotoxy(2,7);
cprintf("known for dropping the most powerful non-nuclear weapon ever.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void f16(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-16 Fighting Falcon");
gotoxy(2,4);
cprintf("The F-16 is a lightweight, multi-role fighter jet made for intense");
gotoxy(2,5);
cprintf("dogfighting and all-around versatility. First flew in the mid-1970s,");
gotoxy(2,6);
cprintf("the F-16's reasonable cost and effectiveness made it a fighter of choice");
gotoxy(2,7);
cprintf("of US and several other nations");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void f15(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-15 Eagle");
gotoxy(2,4);
cprintf("xxxxxxx");
gotoxy(2,5);
cprintf("xxxxxxx");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void a10(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("A-10 Thunderbolt II");
gotoxy(2,4);
cprintf("The A-10 is a rugged close support attack aircraft, the first of its");
gotoxy(2,5);
cprintf("kind in the USAF. Armed with its devastating 30mm Gatling cannon and");
gotoxy(2,6);
cprintf("a variety of munitions, the A-10 can effectively destroy tanks and other");
gotoxy(2,7);
cprintf("ground targets, like its WWII namesake, the P-47 Thunderbolt.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void f35(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-35 Lightning II");
gotoxy(2,4);
cprintf("xxxxxxx");
gotoxy(2,5);
cprintf("xxxxxxx");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void f22(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("F-22 Raptor");
gotoxy(2,4);
cprintf("xxxxxxx");
gotoxy(2,5);
cprintf("xxxxxxx");
gotoxy(2,6);
cprintf("xxxxxxx");
gotoxy(2,7);
cprintf("xxxxxxx");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void b1(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("B-1B Lancer");
gotoxy(2,4);
cprintf("The supersonic variant in the US Air Force's bomber fleet, and after experiencing");
gotoxy(2,5);
cprintf("several setbacks on program costs and on the nature of its role, the B-1B");
gotoxy(2,6);
cprintf("Lancer, nicknamed Bone, is a swing-wing bomber that has been continually");
gotoxy(2,7);
cprintf("upgraded, armed with smart bombs and cruise missiles.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void b2(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("B-2 Spirit");
gotoxy(2,4);
cprintf("The B-2 is a sophisticated stealth bomber, using its design and classified");
gotoxy(2,5);
cprintf("radar-absorbing skin that makes it virtually invisible to radar, alowing");
gotoxy(2,6);
cprintf("it to penetrate enemy airspace undetected. It is a very expensive ");
gotoxy(2,7);
cprintf("aircraft, with each one costing more than a billion dollars.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
void b52(void)
{
int ret1;
clrscr();
gotoxy(2,2);
cprintf("B-52 Stratofortress");
gotoxy(2,4);
cprintf("A Cold War icon, the symbol of the West's nuclear deterrence");
gotoxy(2,5);
cprintf("at that time, and dropping a massive tonnage of bombs in Vietnam, the ");
gotoxy(2,6);
cprintf("B-52 is a versatile heavy bomber that can carry a huge load of cruise missiles");
gotoxy(2,7);
cprintf("or bombs. It is one of the longest-serving aircraft ever.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&air1);
switch(choice)
{
case 1: clrscr();
usa();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
...this is how the program should work (a pain in the ass to explain here):
1. Program will ask for selection (1 to display list of Russian planes, 2 for US planes, 3 to close the program)
2. Inputting either of the first two numbers will display the respective lists
3. Entering one of the indicated keys should display the selection's information which in this case, didn't...
Now, HERE'S THE PROBLEM, as mentioned above, when I input a correct key, in this case "1" for "MiG-29", it displays an invalid input message as if I've typed in a wrong key instead of diplaying the info, which should be:
QUOTE
MiG-29 Fulcrum
The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole
fighter aircraft developed in the 1970s. It became a deadly adversary
against its US counterparts, the F-16 and the F-15. It also saw service
with other nations, and evolved into more sophiscated variants like the MiG-35.
Press 1 to go back
Current selection:
The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole
fighter aircraft developed in the 1970s. It became a deadly adversary
against its US counterparts, the F-16 and the F-15. It also saw service
with other nations, and evolved into more sophiscated variants like the MiG-35.
Press 1 to go back
Current selection:
(section of the above code)
CODE
void mig29(void)
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("MiG-29 Fulcrum");
gotoxy(2,4);
cprintf("The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole");
gotoxy(2,5);
cprintf("fighter aircraft developed in the 1970s. It became a deadly adversary");
gotoxy(2,6);
cprintf("against its US counterparts, the F-16 and the F-15. It also saw service");
gotoxy(2,7);
cprintf("with other nations, and evolved into more sophiscated variants like the MiG-35.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&ret);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
{
int ret;
clrscr();
gotoxy(2,2);
cprintf("MiG-29 Fulcrum");
gotoxy(2,4);
cprintf("The Mikoyan MiG-29, NATO codename Fulcrum, is a Soviet multirole");
gotoxy(2,5);
cprintf("fighter aircraft developed in the 1970s. It became a deadly adversary");
gotoxy(2,6);
cprintf("against its US counterparts, the F-16 and the F-15. It also saw service");
gotoxy(2,7);
cprintf("with other nations, and evolved into more sophiscated variants like the MiG-35.");
gotoxy(2,9);
cprintf("Press 1 to go back");
gotoxy(2,11);
cprintf("Current selection: ");
scanf("%d",&ret);
switch(choice)
{
case 1: clrscr();
rus();
break;
default: gotoxy(2,12);
printf ("Invalid key!");
break;
}
getch();
}
I had a really rough time trying in finding out the problem, need help!