Forum: Hjälp med program

Forum huvudsida -> Programmering -> Hjälp med program

Sidor: 1

Till botten

FlugSimp 15:19 - 15:e November 2008 | Post #1
Medlem
Inlägg: 11


Skicka PM
Hej!Smiley
Jag är nybörjare här och behöver hjälp med tre saker
Det första är att jag undrar om man kan göra så att programmet stängs av om man skriver själv t.ex. escape eller någonting liknande i sitt program (jag andvänder Dos).
Jag använder C++.
Den andra är om man kan göra if satser i andra if satser?
Den tredje är att det är något fel med ett program som jag gjort den vill inte kopileras här är koden.
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. using std::cout;
  5. using std::cin;
  6.  
  7. int main()
  8. {
  9. char Answer_1;
  10. char Answer_2;
  11. char Answer_3;
  12. char Answer_4;
  13. char Answer_5;
  14. char Next_Question_Answer;
  15. char Next_Question_Answer_1;
  16. char Next_Question_Answer_2;
  17. char Next_Question_Answer_3;
  18. char Next_Question_Answer_4;
  19.  
  20. cout << "Are You A Human? \n";
  21. cin >> Answer_1;
  22. }
  23.  
  24. if ((Answer_1 == "Yes") || (Answer_1 == "yes") || (Answer_1 == "Yeah") || (Answer_1 == "yeah"))
  25. {
  26. cout << "Good, Do You Want To Move On To The Next Question? \n";
  27. cin >> Next_Question_Answer;
  28. }
  29. else if ((Answer_1 == "No") || (Answer_1 == "no") || (Answer_1 == "Nope") || (Answer_1 == "nope"))
  30. {
  31. cout << "Ok?? That's Strange... Do You Want To Move On To The Next Question? \n";
  32. cin >> Next_Question_Answer;
  33. }
  34. if (( Next_Question_Answer == "No") || (Next_Question_Answer == "no") || (Next_Question_Answer == "Nope") || (Next_Question_Answer == "nope"))
  35. {
  36. cout << "Ok, Good Bye";
  37. }
  38. else if ((Next_Question_Answer == "Yes") || (Next_Question_Answer == "yes") || (Next_Question_Answer == "Yeah") || (Next_Question_Answer == "yeah"))
  39. {
  40. cout << "Ok, What Is 7236 Multiplyed With 6 Plus 6 Minus 5? \n";
  41. cin >> Answer_2;
  42. }
  43.  
  44. if (Answer_2 == "43417")
  45. {
  46. cout << "I Swear To God That You Used A Calcylator, Do You Want To Move On To The Next Question? \n";
  47. cin >> Next_Question_Answer_1;
  48. }
  49. else
  50. {
  51. cout << "Were You Awake At The Math Lessons? Do You Want To Move On To The Next Question? \n";
  52. cin >> Next_Question_Answer_1;
  53. }
  54. if (( Next_Question_Answer_1 == "No") || (Next_Question_Answer_1 == "no") || (Next_Question_Answer_1 == "Nope") || (Next_Question_Answer_1 == "nope"))
  55. {
  56. cout << "Ok, Good Bye";
  57. }
  58. else if ((Next_Question_Answer_1 == "Yes") || (Next_Question_Answer_1 == "yes") || (Next_Question_Answer_1 == "Yeah") || (Next_Question_Answer_1 == "yeah"))
  59. {
  60. cout << "Allright Third Question, Where Do You Live? \n";
  61. cin >> Answer_3;
  62. }
  63. if ((Answer_3 == "Earth") || (Answer_3 == "earth"))
  64. {
  65. cout << "It Isn't Many People Who Think Like You, Do You Want To Move On To The Next Question? \n";
  66. cin >> Next_Question_Answer_2;
  67. }
  68. else
  69. {
  70. cout << "Allright?... Thats... Umm ... Interesting, Do You Want To Move On To The Next Question? \n";
  71. cin >> Next_Question_Answer_2;
  72. }
  73. if (( Next_Question_Answer_2 == "No") || (Next_Question_Answer_2 == "no") || (Next_Question_Answer_2 == "Nope") || (Next_Question_Answer_2 == "nope"))
  74. {
  75. cout << "Ok, Good Bye";
  76. }
  77. else if ((Next_Question_Answer_2 == "Yes") || (Next_Question_Answer_2 == "yes") || (Next_Question_Answer_2 == "Yeah") || (Next_Question_Answer_2 == "yeah"))
  78. {
  79. cout << "Ok, In Wich Program Is This Question-Game Running In? ";
  80. cin >> Answer_4;
  81. }
  82. if ((Answer_4 == "DOS") || (Answer_4 == "Dos") || (Answer_4 == "dos"))
  83. {
  84. cout << "Good That You're Competent With Computers! Do You Want To Move On To The Next Question?\n";
  85. cin >> Next_Question_Answer_3;
  86. }
  87. else
  88. {
  89. cout << "You Are The Most Incompetent Person I've Ever Met, Do You Want To Move On To The Next Question?\n";
  90. cin >> Next_Question_Answer_3;
  91. }
  92. if (( Next_Question_Answer_3 == "No") || (Next_Question_Answer_3 == "no") || (Next_Question_Answer_3 == "Nope") || (Next_Question_Answer_3 == "nope"))
  93. {
  94. cout << "Ok, Good Bye";
  95. }
  96. else if ((Next_Question_Answer_3 == "Yes") || (Next_Question_Answer_3 == "yes") || (Next_Question_Answer_3 == "Yeah") || (Next_Question_Answer_3 == "yeah"))
  97. {
  98. cout << "Allright Last Question, Who Are You? \n";
  99. cin >> Answer_5
  100. }
  101. if (Answer_5 == "Just_A_Dumbass")
  102. {
  103. cout << "Congratulate, You're The Dumbest Person On Earth! Good Bye And Thanks For Waste Youre Time";
  104. }
  105. else
  106. {
  107. cout << "You're The Super, Rumble, oeber, Dumbest Person In Our Galaxy And Universe! Good Bye And Thanks For Waste Youre Time";
  108. }
  109.  
  110. cin.ignore(255,'\n');
  111. cin.get();
  112. return 0;
  113. }


Snälla någon hjälp mig.

Tack i förväg!

Jag fixa till source-taggar. //herj


Senast redigerad 11:25 - 16:e November 2008


Slash 05:42 - 17:e November 2008 | Post #2
Medlem
Inlägg: 141


Skicka PM
Tjena!

1. ,,r inte så säker på hurvida det går att göra med standardbiblioteket.

2. Ja, det ska gå alldeles utmärkt.

3. Vad får du får kompileringsfel, och på vilka rader? Det som jag ser så här direkt är att du har en måsvinge på rad 22 som inte ser ut att höra hemma där. Dessutom ser ded ut som att du skulle vilja ha string istället för char på rad 9 till 18 och #include <string> högst upp i ditt program.

EDTIT: Missuppfattade en av dina frågor.

-------------------------
Ingen sigantur!

Senast redigerad 06:04 - 17:e November 2008


FlugSimp 20:24 - 17:e November 2008 | Post #3
Medlem
Inlägg: 11


Skicka PM
Hej Slash!
Jag har testat med string och då får jag kompiler fel på raden där det står
if (Answer_5 == "Myself")
(jag har tagit bort måsvingen i början som du sa)




Slash 21:55 - 17:e November 2008 | Post #4
Medlem
Inlägg: 141


Skicka PM
Kan tänka mig att det beror på att du saknar ett semi-kolon på raden ovanför. Rad 99 bör alltså vara:
  1. cin >> Answer_5;


Hoppas det löser sig!

-------------------------
Ingen sigantur!



FlugSimp 17:03 - 19:e November 2008 | Post #5
Medlem
Inlägg: 11


Skicka PM
Nu är det inte kompil fel där nu är det på den sista måsvingen under return 0;




FlugSimp 13:35 - 26:e November 2008 | Post #6
Medlem
Inlägg: 11


Skicka PM
Tack så mycket slash men jag kom på en lösning tack så mycketSmiley




Sidor: 1

Forum huvudsida -> Programmering -> Hjälp med program
Atom feed

Du får inte posta i den här tråden | Till toppen