You are on page 1of 4

Question 1

1. What is the output if the input is 2100? Please explain your answer! How to ensure that output

complies with regulations (2100 is not a leap year)?

-Because the first if statement is (year % 4) which mean if year can divided by 4 it’s a leap year,and if its
not leap year(cant divided by 4) print else(not leap year)

2. Modify the program according to answer number 1!

3. Commit and push the changes into your repository!

-https://github.com/Majid5654/Tugas-kelas/blob/main/pemilihan2perobaan1.java
4. The year 2000 is a multiple of 4 and a multiple of 100, but it is a leap year. So that, there is an

additional rule to determine leap year. If the year is a multiple of 100 and is also a multiple of 400

then that year is a leap year. Modify the program to adjust to these rule! (Create the algorithm

without using logical operators)

5. Commit and push the modifications to the repository!


-https://github.com/Majid5654/Tugas-kelas/blob/main/pemilihan2perobaan1mod.java

Question 2

1. Modify the source code, so that it can detect the other types of triangles (equilateral triangle and

isosceles triangle)

2. Commit and push the changes into your repository

-https://github.com/Majid5654/Tugas-kelas/blob/main/selection2exp208.java
-Question 3

1. Explain the function of (int) in the syntax netSalary= (int) (income - (income * tax));

-The function of (int) in the syntax netSalary=(int)(income-(income*tax));

Is for narrowing casting type since the variable tax used doubke and we want the calculation to turn out
to be a int

2. Run the program by entering category = BUSINESSMAN and income = 2000000. Observe what

happens! What is the use of equalsIgnoreCase?

-The equalsIgnoreCase() method in Java is used to compare two strings while ignoring their case
differences. It returns a boolean value of true if the two strings are equal, and false if they are not. This
method is useful when we want to compare two strings without considering their case sensitivity. For
example, if we have two strings "Hello" and "hello", equalsIgnoreCase() will return true when used to
compare them

3. Change equalsIgnoreCase to equals, then run the program by entering category =

BUSINESSMAN and income = 2000000. Observe what happens! Why is the result like that? What

is the use of equals?


-

-Because its not equals to businessman with no capslock

-The equals() method in Java is used to compare two strings, and returns true if the strings are equal,
and false if they are not. This method compares the content of the strings, and not their memory
location. It is commonly used to determine whether two objects are considered equal based on their
attributes or properties. The equals() method is defined in the Object class, which is the root class for all
Java classes. If a class needs customized equality comparison, it should override this method

3. Assignment

Create a program code based on the flowchart that was created in the 6th Fundamentals

Programming Course meeting assignment related to the Project! Push and commit the results of your

program code to your project repository!

Note: assignments may only apply material from meeting 1 to meeting 6

-https://github.com/Majid5654/Tugas-kelas/blob/main/mod.java

You might also like