a) Write at least two good specifications for the following, /** Compute the square root of a number. @param ?? @returns

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
correctanswer
Posts: 43759
Joined: Sat Aug 07, 2021 7:38 am

a) Write at least two good specifications for the following, /** Compute the square root of a number. @param ?? @returns

Post by correctanswer »

A Write At Least Two Good Specifications For The Following Compute The Square Root Of A Number Param Returns 1
A Write At Least Two Good Specifications For The Following Compute The Square Root Of A Number Param Returns 1 (104.29 KiB) Viewed 59 times
a) Write at least two good specifications for the following, /** Compute the square root of a number. @param ?? @returns ?? @throws ?? if any public static int squareRoot(int x); b) Write non-trivial precondition for the multiply method (e.g. dont write b=0), so that the returned result is a*b. public int mult (int a, int b) { if (b == 0) return b; else return a + mult (a, b-1); } c) Given the following interface class (Mode) with a single method, getMode, that is subsequently implemented by the myMode class. public interface Mode { /** * Finds one of the most frequent integers in an array. * @param values array in which at least one value occurs more than once. * @return a number that appears most often in values */ public int getMode (int[] values); } Along with a class that implements it: public class MyMode implements Mode { /** * TODO */ @Override public int getMode (int[] values) { } } Using class discussion on specification write a spec for MyMode.getMode() in which the precondition and post-condition are both different from Mode.getMode(), while ensuring at the same time that MyMode is a well-defined spec that legally implements Mode. Hint: the new precondition must be weaker and the new post-condition must be stronger.
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply