Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

amen fatima write csc126 Spring 2016 Final-B a value function named allsane that takes four int parameters, and checks returning if the to see if they are all four even or all four odd. The fu returns the numbers are all even and the character nction all odd, and the character 'n' if neither is true. For if e numbers are function will example if the function is sent 4 the return the character 'e' 18.20 a) 2 points) Give the function prototype: b) 2 points) Give an example of the function call: carded Sa me c) (0 points) the function definition (header and body) write

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