Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Adding Game.java #1750

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Games/Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import java.util.Random;
import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author tasmi
*/
public class Game {
public static void main(String []args)
{
int num,ans;
Scanner kb=new Scanner(System.in);
System.out.println("enter a number between 0-20 :");
num=kb.nextInt();
Random n=new Random();
ans=n.nextInt(21);
if(num==ans)
System.out.println("\nCongrats!you won!");
else
System.out.println("\nBetter luck next time!");
System.out.println("\nYou entered : "+num+"\t Number appeared : "+ans);

}

}