Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

U | New g/cis3115/hw1.pdf Q3: Write each of the following functions as static methods in Java. 1. static int ged (int x, int y): Return

image text in transcribed
image text in transcribed
U | New g/cis3115/hw1.pdf Q3: Write each of the following functions as static methods in Java. 1. static int ged (int x, int y): Return the greatest common divisor of x and y 2. static int sumEven(int a): Return the sum of the even integers 3. static boolean sorted (int[] a) Test if array a is sorted in 4. static int copy (int[] a): Return a copy of array a. in array a ascending order. s static int(l eliminateDuplicates (int[) a): Retum a copy of array a without duplicates, For example, for a n2,1,2,2,31,the returned array is (1,2 6. static char tic_tac teo (char[ grid): Given a 3x3 gricd configuration represented as a two-dimensional array, where each entry is or O', returnX' if the configuration is a win for x', O' if the configuration is a win for 'o, and 'D' if the configuration is a draw. 7. static long bin str_to int (String binstr): Convert an unsigned binary string to a decimal integer. For example, for binstr- 11010", the returned integer is 26. New ing/cis3115/hw1.pdf Q3: Write each of the following functions as static methods in Java. 1. static int gcd (int x, int y): Return the greatest common divisor of x and y 2. static int sumEven (inttl a): Return the sum of the even integers 3. static boolean sorted (int[] a):Test if array a is sorted in 4. static intll copy (intl a): Return a copy of array a. in array a. ascending order. 5. static intl] eliminateDuplicates (intl] a): Return a copy of array a without duplicates. For example, for a- [1,2,1,2,2,3], the returned array is [1,2,3]. 6. static char tic tac teo (char[11) grid) : Given a 3x3 grid configuration reprsented as a two-dimensional array, where each entry is 'X or 'O', return x if the configuration is a win for X', 0 if the configuration is a win for 'O', and 'D' if the configuration is a draw. static long bin str_to int (String binstr) Convert an unsigned binary string to a decimal integer. For example, for binstr 11010 the returned integer is 26

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

Compare the different types of employee separation actions.

Answered: 1 week ago

Question

Assess alternative dispute resolution methods.

Answered: 1 week ago

Question

Distinguish between intrinsic and extrinsic rewards.

Answered: 1 week ago