Understanding Java Discussion

 Please respond to the below text in 100 words or more.

While  researching the topic I learned that selective statements are used for  decision making in the code. Selective statements use lines such as if  or else. An example of this would be to find if a number is greater  than or equal to a number in an equation. I wrote the following simple  code in Eclipse to help demonstrate this.

int A=4;

if (A<3||A>3) {

System.out.println(“A is not equal to 3”);

}else {System.out.println(“A is equal to 3”);

The code would see the number 4 and be able to tell you that it is not equal to 3.

Repetitive  statements are different from selective statements as they are used to  repeat the code or are used for looping if they are within the  parameters you have set. Repetitive statements use the for statement,  while statement, and do-while statement.

Using math again for my examples I have used the following codes to show how these statements work.

for (int x = 0; x*2 < 15; x++)

{

System.out.println(x);

In  this example I am using the for statement. Essentially, I am asking the  code to give me all the numbers that can be multiplied by 2 without  going over 15. It will start with 0 and go up one number until 7, as any  integer above 7 would be greater than 15. 

int x = 0;

while (x <= 200)

{

System.out.println(x);

x = x+50;

The  while statement is used here to tell the code that it wants it to  repeat adding 50, while starting at 0 while not going over 200.