Created
February 27, 2015 17:39
-
-
Save eroltutumlu/0626ee1bff7426efbc9e to your computer and use it in GitHub Desktop.
Java ile sayı tahmin
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
package JavaOgreniyorum; | |
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
Random rand = new Random(); | |
final int randomNumber = rand.nextInt(100)+1; | |
int GuessNumber; | |
int RndGss; | |
boolean GameWin = false; | |
Scanner input = new Scanner(System.in); | |
while(!GameWin) | |
{ | |
System.out.println("Tahmin: "); | |
GuessNumber = input.nextInt(); | |
RndGss = Math.abs(GuessNumber-randomNumber); | |
if(RndGss>0 && RndGss<=5){ | |
System.out.println("Sayıya çok yaklaştınız ortam çok sıcak."); | |
} | |
else if(RndGss>5 && RndGss<=15){ | |
System.out.println("Sayıya yaklaştınız ortam sıcak."); | |
} | |
else if(RndGss>15 && RndGss<=25){ | |
System.out.println("Sayıya yaklaştınız ortam ılık."); | |
}else if(RndGss>25 && RndGss<=35){ | |
System.out.println("Ortam norml."); | |
} | |
else if(RndGss>35 && RndGss<=45){ | |
System.out.println("Sayıdan uzaklaştınız ortam soğuk."); | |
} | |
else if (RndGss>45){ | |
System.out.println("Çok çok soğuk."); | |
} | |
else{ | |
System.out.println("Tebrikler"); | |
GameWin = true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment