I want to make a program where i can give an interval for my input. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I want to make a program where i can give an interval for my input.

...if my input not belong to the interval, then the program will close automatically.can anyone give me code for my questionex: int x; interval -> 0<x<100if x not belong to the interval, then program automatically out

7th Sep 2016, 11:51 AM
Farhan Sindy
Farhan Sindy - avatar
4 Answers
+ 2
Just use an if. public void foobar(int x, int ll, int hl) { if ((x >= ll) && (x <= hl)) { //... } }
7th Sep 2016, 12:27 PM
Zen
Zen - avatar
+ 1
and, how to make program to close with automatically
7th Sep 2016, 5:39 PM
Farhan Sindy
Farhan Sindy - avatar
0
if i understand you correct, to close your program you can call System.exit(0); the zero can be any other integer value. it helps you to unterstand why and where your program quit
11th Sep 2016, 12:14 AM
Tucura
Tucura - avatar
- 3
do you want to help me , you give a money small $5
7th Sep 2016, 12:22 PM
Saed Abdulahi Shire
Saed Abdulahi Shire - avatar