Computer Science, asked by kshitih, 1 year ago

write a program to input 3 numbers and check that they all are positive integers if all are positive then print which are even if all are even then print its last digit if all are odd then what should be added to a to make it even print the number

Answers

Answered by thepandalover55
1
import java.util.*;
public class positive
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter 3 nos");
int n =sc.nextInt();
int m =sc.nextInt();
int o=sc.nextInt();
If(n>0 && m>0 && o>0)
{
If(n%2==0)
System.out.println(n);
If(m%2==0)
System.out.println(m);
If(o%2==0)
System.out.println(o);
If(n%2==0 && m%2==0 && o%2==0)
for(int i =n; i<10 && i>0; i%10)
System.out.print();
for(int j =m; j<10 && j>0; j%10)
System.out.print();
for(int k =o; k<10 && k>0; k%10)
System.out.print();
System.out.println(i);
System.out.println(j);
System.out.println(k);
}
else
{
System.out.println("1 Should be added to the present numbers to make them even. ");
}
}
}

Hope it helps...

kshitih: can u solve it without using function argument and stream readers ,and logical operators and by using nested if
thepandalover55: ok
thepandalover55: I'll try
thepandalover55: wait for some time
Similar questions