AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-programming: Check whether a given number is teen or not?

We´ll say that a number is "teen" if it is in the range 13 to 19 inclusive. Given 2 integer values, print the number that is the teen range. Sample Input: 12 14 Sample Output: 12 and 14 both are teen numbers Sample Input: 21 25 Sample Output: 21 and 25 both are not teen numbers Sample Input: 17 89 Sample Output: 17 is a teen number Template: import java.util.*; public class Program3 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int b=sc.nextInt(); //Write your code here } }

corejava x 336
programming x 153
Posted On : 2016-12-23 10:54:03.0
profile Navin Kumar - anyforum.in Navin Kumar
600
up-rate
4
down-rate

Answers


Check this code and let me know if your conditions satisfied or not.

import java.util.Scanner;
class TeenNumbers
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int a=s.nextInt();
int b=s.nextInt();
if((a>=13&&a<=19)&&(b>=13&&b<=19))
{
System.out.println(a+"and"+b+"both are teen numbers");
}
else if((a>=13&&a<=19)||(b>=13&&b<=19))
{
if(a>=13&&a<=19)
{
System.out.println(a+"is a teen number");
}
else
{
System.out.println(b+"is a teen number");
}
}
else
{
System.out.println(a+"and"+b+"both are not teen numbers");
}
}
}

Posted On : 2016-12-24 01:04:37
Satisfied : 4 Yes  0 No
profile sudheerkumar Javvadi - anyforum.in sudheerkumar Javvadi
0970
Reply This Thread
up-rate
4
down-rate
Comments
out of 4 0 test case passed
profile nav raj - anyforum.in nav raj
12  0  0
Posted On :2016-12-24 19:34:24.0
Leave a Comment
out of 4 0 test case passed
profile nav raj - anyforum.in nav raj
12  0  0
Posted On :2016-12-24 19:34:56.0
Leave a Comment



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in