Skip to content

Commit f4dafa8

Browse files
Create 15.2 Number Game.java
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n>=0 && n<=99) { for(int i=0;i<=n;i++) System.out.println(i); System.out.print("Games End"); } else System.out.print("Invalid Input"); } }
1 parent 9792f3a commit f4dafa8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

15.2 Number Game.java

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Neha and Nisha are playing a game .Nisha ask Neha to enter the number N from given range of 0 to 99 .Now Nisha need to print the number till N and once it exceed the number from N then Print "Games End".If Neha enter the number less then 0 print Invalid input.
3+
4+
Input Format
5+
6+
Program should take the input for Number N.
7+
8+
Constraints
9+
10+
0>=N<100
11+
12+
Output Format
13+
14+
Print the number till N and if the range of N exceed print "Games End”.If Neha enter the number less then 0 print "Invalid Input".
15+
16+
Sample Input 0
17+
18+
5
19+
Sample Output 0
20+
21+
0
22+
1
23+
2
24+
3
25+
4
26+
5
27+
Games End
28+
Sample Input 1
29+
30+
-10
31+
Sample Output 1
32+
33+
Invalid Input
34+
*/
35+
import java.io.*;
36+
import java.util.*;
37+
38+
public class Solution {
39+
40+
public static void main(String[] args) {
41+
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
42+
Scanner sc = new Scanner(System.in);
43+
44+
int n = sc.nextInt();
45+
if(n>=0 && n<=99)
46+
{
47+
for(int i=0;i<=n;i++)
48+
System.out.println(i);
49+
50+
System.out.print("Games End");
51+
}
52+
else
53+
System.out.print("Invalid Input");
54+
55+
}
56+
}

0 commit comments

Comments
 (0)