how to create java games | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

how to create java games

10th Aug 2016, 7:14 AM
Anjaan muthu
Anjaan muthu - avatar
2 Answers
+ 1
import java.util.Scanner; class Game{ public static void main(String[] args){ int numberToGuess = 7; Scanner input = new Scanner(System.in); System.out.println("Guess the number"); int numberGuessed = input.nextInt(); if(numberToGuess == numberGuessed){ System.out.println("Congratulations! The correct number was " + numberToGuess); }else{ System.out.println("Nope, you lose!"); } } } Boom, a game. Learn coding, and you can do it too :).
10th Aug 2016, 7:29 AM
James
James - avatar
0
ok
10th Aug 2016, 8:55 AM
Pankaj Kumar
Pankaj Kumar - avatar