전체 글(37)
-
Coding Exercise 10: Equality Printer
Write a method printEqual with 3 parameters of type int. The method should not return anything (void). If one of the parameters is less than 0, print text "Invalid Value". If all numbers are equal print text "All numbers are equal". If all numbers are different print text "All numbers are different". Otherwise, print "Neither all are equal or different". public class IntEqualityPrinter { public ..
2021.03.01 -
Coding Exercise 9: Minutes To Years and Days Calculator
Write a method printYearsAndDays with parameter of type long named minutes. The method should not return anything (void) and it needs to calculate the years and days from the minutes parameter. If the parameter is less than 0, print text "Invalid Value". Otherwise, if the parameter is valid then it needs to print a message in the format "XX min = YY y and ZZ d". XX represents the original value ..
2021.02.27 -
Coding Exercise 8: Area Calculator
Write a method named area with one double parameter named radius. The method needs to return a double value that represents the area of a circle. If the parameter radius is negative then return -1 to represent an invalid value. Write another overloaded method with 2 paramters x and y (both doubles), where x and y represent the sides of rectangle. The method needs to return an area of a rectangle..
2021.02.26 -
Coding Exercise 7: Teen Number Checker
We'll say that a number is "teen" if it's in the range 13 to 19 (inclusive). Write a method named hasTeen with 3 parameters of type int. The method should return boolean and it needs to return true if one of the parameters is in range 13 (inclusive) to 19 (inclusive). Otherwise, return false. public class TeenNumberChecker { public static boolean hasTeen(int num1, int num2, int num3){ if (13
2021.02.25 -
Coding Exercise 6: Equal Sum Checker
Write a method hasEqualSum with 3 parameters of type int. The method should return boolean and it needs to return true if the sume of the first and second parameter is equal to the third parameter. Otherwise, return false. public class EqualSumChecker { public static boolean hasEqualSum(int num1, int num2, int num3){ if (num1 + num2 == num3){ return true; } else { return false; } } } 굿굿~~
2021.02.24 -
Coding Exercise 5: Decimal Comparator
Write a method areEqualByThreeDecimalPlaces with two parameters of type double. The method should return boolean and it needs to return true if two double numbers are the same up to three decimal places. Otherwise, return false. public class DecimalComparator { public static boolean areEqualByThreeDecimalPlaces (double num1, double num2) { if (Math.round(num1 * 1000) < 0 || Math.round(num2 * 100..
2021.02.23