same question plz do a,b and c amen fatima write csc126 Spring 2016 Final-B a va
ID: 3581144 • Letter: S
Question
same question plz do a,b and c
Explanation / Answer
a) int allSame(int num1,int num2,int num3,int num4);
b) allSame(4,6,18,20);
c)
import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
char allSame(int num1,int num2,int num3,int num4)
{
if((num1 % 2) == 0 && (num2 % 2) == 0 && (num3 % 2) == 0 && (num4 % 2) == 0)
return 'e';
if((num1 % 3) == 0 && (num2 % 3) == 0 && (num3 % 3) == 0 && (num4 % 3) == 0)
return 'o';
else
return 'n';
}
public static void main (String[] args)
{
Ideone obj = new Ideone();
char ch;
ch = obj.allSame(4,6,18,20);
System.out.println(ch);
ch = obj.allSame(3,6,18,21);
System.out.println(ch);
ch = obj.allSame(4,6,18,21);
System.out.println(ch);
}
}
Output :
e
o
n
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.