OperatorExercise.java
This program was created just to practice some operators specifically the increment operators.
Believed that it was code from a quiz or something to do with studying for a quiz.
The code has been modified slightly and now uploaded to the site.
Code Snippet
/*
Author: ENTPRESTIGIOUS
Date Finished: April 15, 2021
Compiler: JDK 11.0.10 LTS
*/
public class OperatorExercise {
public static void main(String[] args){
exerciseOne();
exerciseTwo();
exerciseThree();
exerciseFour();
}
public static void exerciseOne(){
int a = 5;
int x = 3 + ++a +4;
System.out.println("Exercise One: " +x);
System.out.println("Exercise One: " +a);
}
public static void exerciseTwo(){
int a = 5;
int x = 3 - a++ +4;
System.out.println("Exercise Two: " +x);
System.out.println("Exercise Two: " +a);
}
public static void exerciseThree(){
int a = 7;
int x = 10 - --a +3;
System.out.println("Exercise Three: " + x);
System.out.println("Exercise Three: " + a);
}
public static void exerciseFour(){
int a = 7;
int x = 7 + a-- -3;
System.out.println("Exercise Four: " + x);
System.out.println("Exercise Four: " + a);
}
}