Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp : Defines the entry point for the console application.
- // Rihards Heinerihs Sakalis
- /*UNIT 16 Assignment 2*/
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- /*Welcoming screen*/
- cout << "///////////////////////////////////////////////////////////////////////////////// \n\n";
- cout << " \n\n ";
- cout << " Welcome to the Maths game! \n\n";
- cout << " \n\n";
- cout << "///////////////////////////////////////////////////////////////////////////////// \n\n";
- system("pause");
- system("cls");
- int ans;
- int score = 0; //This is used to create a score system
- string username;
- string password;
- bool success;
- cout << "\tWelcome, please type in the login details to proceed. The guest's login - Username = guest Password = guest\n\n";
- do
- {
- cout << endl << "Username: ";
- cin >> username;
- cout << endl << "Password: ";
- cin >> password;
- if (username == "rihard" && password == "sakalis") // My personal Login
- {
- cout << endl << "Hey, Rihard's, ";
- success = true;
- }
- else if (username == "guest" && password == "guest")// Login for a guest
- {
- cout << endl << "Welcome, Guest, ";
- success = true;
- }
- else
- {
- cout << endl << "your login failed."; // If you fail to input the correct details, this message will display.
- success = false;
- }
- } while (!success);
- system("pause");
- system("cls");
- {
- cout << " You will have 7 questions to answer, do not use the calculator!, Good luck \n";
- }
- cout << "One more thing before you start, remember to do the Multiplications / Dividing first - BIDMAS!\n\n";
- cout << "1) 3 + 3 * 3 = "; // Question you have to answer.
- cin >> ans;
- if (ans == 12) //This is the correct answer to the qeustion, if he answers it correctly he gets an extra point.
- {
- ++score;
- cout << "Nice! You gained an extra point! " << score << endl << endl; // - The extra pooint ^
- }
- else
- {
- cout << "Wrong answer. Your current score is: " << score << endl << endl;
- }
- cout << "2) 26 + 3 * 8 = ";
- cin >> ans;
- if (ans == 50)
- {
- ++score;
- cout << "Nice! You gained an extra point! " << score << endl << endl;
- }
- else
- {
- cout << "Wrong answer. Your current score is: " << score << endl << endl;
- }
- cout << "3) 9 + 77 / 7 = ";
- cin >> ans;
- if (ans == 20)
- {
- ++score;
- cout << "Nice! You gained an extra point! " << score << endl << endl;
- }
- else
- {
- cout << "Wrong answer. Your current score is: " << score << endl << endl;
- }
- cout << "4) 33 + 22 + 11 = ";
- cin >> ans;
- if (ans == 66)
- {
- ++score;
- cout << "Nice! You gained an extra point! " << score << endl << endl;
- }
- else
- {
- cout << "Wrong answer. Your current score is: " << score << endl << endl;
- }
- cout << "5) 12 * 20 = ";
- cin >> ans;
- if (ans == 240)
- {
- ++score;
- cout << "Nice! You gained an extra point! " << score << endl << endl;
- }
- else
- {
- cout << "Wrong answer. Your current score is: " << score << endl << endl;
- }
- cout << "6) 7 * 2 + 10 = ";
- cin >> ans;
- if (ans == 24)
- {
- ++score;
- cout << "Nice! You gained an extra point! " << score << endl << endl;
- }
- else
- {
- cout << "Wrong answer. Your current score is: " << score << endl << endl;
- }
- cout << "7) 420 - 377 = ";
- cin >> ans;
- if (ans == 43)
- {
- ++score;
- cout << "Nice! You gained an extra point! " << score << endl << endl;
- }
- else
- {
- cout << "You answered the question wrong. Your final score is: " << score << endl << endl;
- }
- cout << "Thanks for playing my game, ";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement