if problem with range of numbers
i want to show at the output that if the user input is in between 9.01 to 10.00 then it will print A ...and same i want to use it for some other values.. is there any way so that i can use a range in if statement ...or i have to write the complete set of nos in if statement ...
plzzz helpppp...
Re: if problem with range of numbers
The way to test for a range of numbers would be to use the > and the < operators. The numbers between 6 and 10 are > 6 and < 10.
The operators take two operands. If you put them in ()s it will help you format them correctly.
(x>6) && (x<10)
Re: if problem with range of numbers
Please do not post multiple copies of the same question. I've deleted your duplicate thread.
Also, please read the link in my signature on asking questions the smart way. Especially the bit about using proper spelling and grammar.
Re: if problem with range of numbers
Try something like this. Read up on your and(&&) and or(||) condisions. You will meet them very often.
char letter = 'A';
System.out.println("Enter a value between 9.01 and 10.00 ");
//read in a value from user and store in double num;
if (num > 9.00 && num <= 10.00)
System.out.println(letter);