전체 글(37)
-
Coding Exercise 4: Leap Year Calculator
Write a method isLeapYear with a parameter of type in named yaer. The parameter needs to be greater than or equal to 1 and less than or equal to 9999. If the parameter is not in that range return false. Otherwise, if it is in the valid range, calculate if the year is a leap year and return true if it is a leap year, otherwise return false. To determine whether a year is a leap year, follow these..
2021.02.20 -
Coding Exercise 3: Barking Dog
Barking Dog We have a dog that likes to bark. We need to wake up if the dog is barking at night. Write a method shouldWakeUp that has 2 parameters. 1st parameter should be of type booleanand be named barking it represents if our dog is currently barking. 2nd paramter represents the hour of the day and is of type int with the name hourOfDay and has a valid range of 0-23. We have to wake up if the..
2021.02.18 -
Coding Exercise 2: MegaBytes Converter
MegaBytes Converter Write a mothod called printMegaBytesAndKiloBytes that has 1 paramter of type int with the name kiloBytes. The method should nt return anything (void) and it needs to calculate the megabytes and remaining kilobytes from the kilobytes parameter. Then it needs to print a message in the format "XX KB = YY MB and ZZ KB". XX represents the orignial value kiloBytes. YY represents th..
2021.02.18 -
Coding Exercise 1: Speed Converter
Speed Converter 1. Write a method called toMilesPerHour that has 1 parameter of type double with the name kilometersPerHour. This method needs to return the rounded value of the calculation of type long. If the parameter kilometersPerHour is less than 0, the method toMilesPerHour neds to return -1 to indicate an invalid value. Otherwise, if it is positive, calculate the value of miles per hour, ..
2021.02.18 -
Operators, Operands and Expressions
Operators in Java are special symbols that perform specific operations on one, two, or three operands, and then return a result. As an example we used the + (addition) operator to sum the value of two variables in a previous chapter. An operand is a term used to describe any object that is manipulated by an operator. If we consider this statement. int myVar = 15 + 12; Then + is the operator, and..
2021.02.17 -
float and double Primitive Types
byte, short, long, width의 차이점과 각각 maximum values와 minimum values에 대해 배웠다! so far so good! package academy.learnprogramming; public class Main { public static void main(String[] args) { int myValue = 10000; int myMinIntValue = Integer.MIN_VALUE; int myMaxIntValue = Integer.MAX_VALUE; System.out.println(myValue); System.out.println("Integer Minimum Value = " + myMinIntValue); System.out.println("I..
2021.02.17