Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-----JAVA Implementations----------------------- public class Lab01 { private Lab01() { // empty by design } //Question 1 /** * Returns the minimum (most negative) value that

-----JAVA Implementations-----------------------

public class Lab01 {

private Lab01() {

// empty by design

}

//Question 1

/**

* Returns the minimum (most negative) value that an int can

* represent.

*

* @return the minimum (most negative) value that an int can represent

*/

public static int minInt() {

return 0;

}

/**

* Returns the minimum positive value greater than zero that a

* double can represent.

*

* @return the minimum positive value greater than zero that a double can

* represent

*/

public static double maxDouble() {

return 0;

}

//Ques 2

/**

* Removes the last two digits of a positive integer base 10 number that is

* greater than 99.

*

* @param n

* a positive integer number greater than 99

* @return the integer produced by removing the last two digits of n

*/

public static int removeLastTwoDigits(int n) {

return 0;

}

/**

* Returns the last one digit of a positive integer base 10 number that is

* greater than 9. If the last two digits start with a

* 0 then only the last digit is returned.

*

* @param n

* a positive integer number greater than 9

* @return the last one digit of n

*/

public static int lastOneDigit(int n) {

return 0;

}

public static int lastTwoDigits(int n) {

return 0;

}

/**

* Computes the age (in years) of a person using the following convoluted

* algorithm:

*

*

*

*

  • start with the person's street address

    *

  • double it

    *

  • add 42 to the result from the previous step

    *

  • multiply the previous step by 50

    *

  • subtract the person's birthYear from the previous step

    *

  • subtract 50 from the previous step

    *

  • add the number of birthdays the person has had this year

    * to the previous step

    *

  • subtract 34 from the previous step

    *

  • the last two digits of the previous step is the age of the person

    *

*

*

* This algorithm works only for people aged 1-99, and for addresses less

* than approximately 20000000.

*

* @param address

* the person's street address number

* @param birthYear

* the person's birth year

* @param birthdays

* the number of birthdays the person has had this year (either 0

* or 1)

* @return the age of the person

*/

public static int yourAge(int address, int birthYear, int birthdays) {

return 0;

}

//Ques 3

/**

* Computes the standard Rayleigh distribution probability density function (see

* the lab document for the actual formula) with scale parameter.

*

* @param x

* a value

* @param sigma

* scale parameter

* @return the standard Rayleigh distribution probability density function

* evaluated at x

*/

public static double rayleigh(double x, int sigma) {

return 0;

}

//Ques 4

/**

* Computes the number of characters that are different in

* two strings of equal length. The strings are compared

* character by character and the number of characters that

* differ is returned. For example:

*

*

 

* Lab1.distance("talk", "talk") returns 0

* Lab1.distance("talk", "walk") returns 1

* Lab1.distance("well", "walk") returns 2

*

*

*

* @param s a non-null string

* @param t a non-null string

* @return the number of characters that differ between s and t

* @throws IllegalArgumentException if s and t have different lengths

*/

public static int distance(String s, String t) {

return 0;

}

//Ques 5

/**

* Determine if the point (x, y) is strictly inside the r

* with center (0, 0) and having radius equal to

* 1. A point on the perimeter of the circle is considered

* outside of the circle.

*

* @param x

* the x-coordinate of the point

* @param y

* the y-coordinate of the point

* @return true if (x, y) is inside the unit circle, and false otherwise

*/

public static boolean isInside(double x, double y) {

return false;

}

//Ques 6

/**

* Returns true if year is a leap year and false otherwise.

*

*

* A year is always a leap year if it is evenly divisible by 400; for all other

* years, a year is a leap year if it is evenly divisible by 4 and not evenly

* divisible by 100. For example:

*

*

 

* isLeapYear(2000) returns true (2000 is divisible by 400)

* isLeapYear(1900) returns false (1900 is divisible by 4 and 100)

* isLeapYear(2004) returns true (2004 is divisible by 4 but not 100)

* isLeapYear(2005) returns false (2005 is not divisible by 4)

*

*

* @param year

* a year

* @return true if year is a leap year and false otherwise

* @throws IllegalArgumentException

* if year is less than 1582 (the year the Gregorian

* calendar was adopted)

*/

public static boolean isLeapYear(int year) {

return false;

}

//Ques 7

/**

* Determine if a value x is strictly inside the given

* Range. A value exactly at the minimum or maximum of the range is

* considered outside of the range.

*

* @param x

* a value

* @param range

* a Range to check

* @return the value 1 if x is strictly inside the given Range, and 0 otherwise

*/

public static int contains(double x, Range range) {

return 0;

}

}

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

Do these strategies lead to biased or irrational decisions?

Answered: 1 week ago

Question

3. Contrast relational contexts in organizations

Answered: 1 week ago

Question

2. Describe ways in which organizational culture is communicated

Answered: 1 week ago

Question

1. Describe and compare approaches to managing an organization

Answered: 1 week ago