c++ program krashar.
Hej, jag håller på att lära mig c++ och för att lära mig så skriver jag ett lite matematiks program, det har funkat bra till nu när det börjat krasha. Det kommer upp en ruta över konsolen som säger "Mathematics har slutat svara". Behöver lite hjälp. Jag har suttit och klurat och testat lite för att lära mig av mitt misstag men jag kommer inte på vad som är felet. Så vad kan felet vara? PS: snälla gnäll inte och säg: ohh lägg ner med programmering du kan fan inget skit dålig kod osv. Det är mitt första arbete och jag har lärt mig detta fort. Och ingen kan allt i början.
#include <cstdlib>
#include <iostream>
#include "stdlib.h"
using namespace std;
int main()
{
unsigned short int money;
unsigned short int answerOne;
unsigned short int answerTwo;
unsigned short int answerThree;
char Y;
char b;
string choice;
string start = start;
string about = about;
string exit = exit;
b = b;
Y = Y;
money = 0;
answerOne = 17;
answerTwo = 27;
answerThree = 10;
system ("TITLE Mathematics");
system ("COLOR 0B");
menu:
cout << ("Welcome to Mathematics\n");
cout << endl;
cout << ("START");
cout << endl;
cout << ("ABOUT");
cout << endl;
cout << ("EXIT");
cout << endl;
cin >> choice;
if (choice == start)
{
goto questOne;
}
if (choice == about)
{
goto about;
}
if (choice == exit)
{
goto exit;
}
else
{
goto menu;
}
about:
cout << ("This game is made by Fredrik Dahl\n");
cout << ("This is my first ever made c++ program\n");
cout << ("Hope you like it!\n");
cin >> b;
if (b == b)
{
goto menu;
}
questOne:
system ("cls");
cout << ("Quest");
cout << endl;
cout << endl;
cout << endl;
cout << ("What is 5 + 12?");
cout << endl;
cout << endl;
cout << ("Reward: 20p");
cout << endl;
cout << endl;
cout << ("Current money: ");
cout << money;
cout << endl;
cout << endl;
cin >> answerOne;
if (answerOne == 17)
{
system ("cls");
system ("COLOR 0A");
cout << ("Congratualtionz!");
cout << endl;
cout << ("Reward: 20p");
money = money + 20;
cout << endl;
cout << ("Current money: ");
cout << money;
cout << endl;
cout << endl;
cout << ("Write y and press enter to proceed");
cout << endl;
cin >> Y;
if (Y == Y)
goto questTwo;
else
goto menu;
}
else
{
system ("cls");
system ("COLOR 0C");
cout << ("Incorrect, try again");
cout << endl;
cin >> b;
if (b == b)
goto questOne;
}
questTwo:
system ("cls");
system ("COLOR 0B");
cout << ("Quest2");
cout << endl;
cout << endl;
cout << ("What is 3*9?");
cout << endl;
cout << endl;
cout << ("Reward 25p");
cout << endl;
cout << endl;
cout << ("Current money: ");
cout << money;
cout << endl;
cout << endl;
cin >> answerTwo;
if (answerTwo == 27)
{
system ("cls");
system ("COLOR 0A");
cout << ("Congratulations!");
cout << endl;
cout << ("Reward 25p");
money = money + 25;
cout << endl;
cout << ("Current money: ");
cout << money;
cout << endl;
cout << ("Write Y and press enter to proceed");
cout << endl;
cin >> Y;
if (Y == Y)
goto questThree;
else
goto menu;
}
else
{
system ("cls");
system ("COLOR 0C");
cout << ("Incorrect, try again");
cout << endl;
cin >> b;
if (b == b)
goto questTwo;
}
questThree:
system ("cls");
system ("COLOR 0B");
cout << ("Quest3");
cout << endl;
cout << endl;
cout << ("What is 53/5?\n");
cout << ("Just write the interger");
cout << endl;
cout << endl;
cout << ("Reward: 30p");
cout << endl;
cout << ("Current money: ");
cout << money;
cout << endl;
cout << endl;
cin >> answerThree;
if (answerThree == 10)
{
system ("cls");
system ("COLOR 0A");
cout << ("Congratulations!");
cout << endl;
cout << ("Reward: 30p");
cout << endl;
cout << endl;
cout << ("Current money: ");
cout << money;
cout << endl;
cout << endl;
cout << ("Write Y and press enter to proceed.");
cout << endl;
cin.get();
}
else
{
system ("cls");
system ("COLOR 0C");
cout << ("Incorrect, try again");
cin >> b;
if (b == b)
goto questThree;
}
exit:
cin.get();
return 0;
}