전체 글(37)
-
Coding Exercise 34: Complex Operations
A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers, and i is a solution of the equation x2 = -1. Because no real number satisfies this equation, i is called an imaginary number. For the complex number a + bi, a is called the real part, and b is called the imaginary part. To add or subtract two complex numbers, just add or subtract the correspond..
2021.04.09 -
Coding Exercise 33: Carpet Cost Calculator
The Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor (width times length) by the price per square meter of carpet. For example, the area of the floor that is 12 meters long and 10 meters wide is 120 square meters. To cover the floor with a carpet that costs $8 per square m..
2021.04.08 -
Coding Exercise 32: Point
You have to represent a point in 2D space. Write a class with the name Point. The class needs two fields with name x and y of type int. The class needs to have two constructors. The first constructor does not have any parameters. The second constructor has parameters x and y of type int and it needs to initialise the fields. Write the following methods : * Method named getX without any parameter..
2021.04.07 -
Coding Exercise 31: Wall Area
Write a class with the name Wall. The class needs two fields with name width and height of type double. The class needs to have two constructors. The first constructor does not have any parameters. The second constructor has parameters width and height of type double and it needs to initialise the fields. In case the width is less than 0 it needs to set the width field value to 0, in case the he..
2021.04.06 -
Coding Exercise 30: Person
Write a class with the name Person. The class needs three fields with the names firstName, lastName of type String and age of type int. Write the following methods: *Method named getFirstName without any parameters, it needs to return the value of the firstName field. *Method named getLastName without any parameters, it needs to return the value of the lastName field. *Method named getAge withou..
2021.04.05 -
Coding Exercise 29: Sum Calculator
Write a class with the name SimpleCalculator. The class needs two fields with names firstNumber and secondNumber both of type double. Write the following methods: *Method named getFirstNumber without any parameters, it needs to return the value of firstNumber field. *Method named getSecondNumber without any parameters, it needs to return the value of secondNumber field. *Method named setFirstNum..
2021.04.04