Klein Prep Computer Science
*********
*********
Due Date: March 4, 2024
Modulus of 3's
/* Instructions:
* Return true if the given non-negative number is
* a multiple of 3 or a multiple of 5.
*
* Use the % "mod" operator
*
* or35(3) → true
* or35(10) → true
* or35(8) → false
*
* Note: your value for this exercise will be different based on your seat number
*/
remainder 3 - Click here.
*********
*********
*********
*********
*********
*********
PX_JavaOperators_lastname(4 files)
Purpose: To build a java programs that shows all the java operators..
/* Instructions:
* Copy the java program code below.
*/
You will need to create the following 4 files:
PX_JavaOperators_lastname.java (Actual Java program)
PX_JavaOperators_lastname.txt (Copy of Java program)
PX_JavaOperators_lastname.png (Screen shot of program running)
PX_JavaOperators_lastname.mp4 (Video of you running the program)
Due Date: March 22, 2024
public class MathOperatorsDemo {
public static void main(String[] args) {
// Declare variables
int a = 10;
int b = 5;
// Addition
int addition = a + b;
System.out.println("Addition: " + a + " + " + b + " = " + addition);
// Subtraction
int subtraction = a - b;
System.out.println("Subtraction: " + a + " - " + b + " = " + subtraction);
// Multiplication
int multiplication = a * b;
System.out.println("Multiplication: " + a + " * " + b + " = " + multiplication);
// Division
int division = a / b;
System.out.println("Division: " + a + " / " + b + " = " + division);
// Modulus (remainder)
int modulus = a % b;
System.out.println("Modulus: " + a + " % " + b + " = " + modulus);
// Unary minus and plus
int unaryMinus = -a;
int unaryPlus = +b; // Generally, this does not change the value
System.out.println("Unary Minus: -" + a + " = " + unaryMinus);
System.out.println("Unary Plus: +" + b + " = " + unaryPlus);
// Increment operators
int preIncrement = ++a; // Increments a by 1, then returns a
int postIncrement = b++; // Returns b, then increments b by 1
System.out.println("Pre-Increment: ++a = " + preIncrement);
System.out.println("Post-Increment: b++ = " + postIncrement + " (b becomes " + b + " after operation)");
// Decrement operators
int preDecrement = --a; // Decrements a by 1, then returns a
int postDecrement = b--; // Returns b, then decrements b by 1
System.out.println("Pre-Decrement: --a = " + preDecrement);
System.out.println("Post-Decrement: b-- = " + postDecrement + " (b becomes " + b + " after operation)");
}
}
*********
*********