Last active
September 1, 2020 06:08
-
-
Save zontyp/8f7bffc585f6f55efff70b5bf3a91680 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'dart:io'; | |
add (int first,int second,int playeranswer) | |
{ | |
if (first + second == playeranswer) | |
{ | |
print ("you got it!"); | |
} | |
if (first + second != playeranswer) | |
{ | |
print ("Better Luck next time!"); | |
} | |
} | |
subtract (int first,int second, int playeranswer) | |
{ | |
if (first - second == playeranswer) | |
{ | |
print ("you got it!"); | |
} | |
if (first - second != playeranswer) | |
{ | |
print ("Better Luck next time!"); | |
} | |
} | |
multiply (int first,int second,int playeranswer) | |
{ | |
if (first * second == playeranswer) | |
{ | |
print ("you got it!"); | |
} | |
if (first * second != playeranswer) | |
{ | |
print ("Better Luck next time!"); | |
} | |
} | |
divide (int first,int second,int playeranswer) | |
{ | |
if (first/second == playeranswer) | |
{ | |
print ("you got it!"); | |
} | |
if (first/second != playeranswer) | |
{ | |
print ("Better Luck next time!"); | |
} | |
} | |
main () | |
{ | |
var playeroperation = stdin.readLineSync (); | |
var level = stdin.readLineSync(); | |
Random r = Random (); | |
var first; | |
var second; | |
if (level == "easy") | |
{ | |
first = r.nextInt (1500); | |
second = r.nextInt (1000); | |
} | |
if (level == "medium") | |
{ | |
first = r.nextInt (100000); | |
second = r.nextInt (10000); | |
} | |
if (level == "hard") | |
{ | |
first = r.nextInt (10000000); | |
second = r.nextInt (1000000); | |
} | |
print (first); | |
print (second); | |
var playeranswer = int.parse(stdin.readLineSync ()); | |
if (playeroperation == "+") | |
{ | |
add (first,second,playeranswer); | |
} | |
if (playeroperation == "-") | |
{ | |
subtract (first,second,playeranswer); | |
} | |
if (playeroperation == "*") | |
{ | |
multiply (first,second,playeranswer); | |
} | |
if (playeroperation == "/") | |
{ | |
divide (first,second,playeranswer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment