39 CHALLENGE OPERATOR
1 CREATE A DOUBLE VAR OF 20.00
2 CREATE A SEC VAR OF TYPE DOBLE 80.00
3 ADD BOTH NOs AND MULTIPLY BY 100.00
4 USE REMAINDER OPERATOR TO FIGURE OUT THE REMAINDER FROM THE RESULT OF THE OPERATION IN STEP 3 AND 40.00. WE USED THE MODULUS OPERATOR ON INTS IN COURSE,BUT WE CAN ALSO USE THE DOUBLE.
5 CREATE A BOOLEAN VAR THAT ASSIGNS TRUE IF THE REMAINDER IN #4 IS 0 OR FALSE IF ITS NOT ZERO.
6OUTPUT BOOLEAN VAL.
7 WRITE AN IF ELSE STATEMENT THAT DISPLAYS A MESSAGE "GOT SOME REMAINDER'.
package com.cnc;
public class Main {
public static void main(String[] args) {
double a = 20.00d;
double b = 80.00d;
double c = a+b;
double e = c*100;
double rem = e%40.00d;
boolean g= (rem == 0) ? true : false;
System.out.println("The remainder is "+rem);
if (!g) {
System.out.println("Got some remainder");
}
}
}OUTCOME
The remainder is 0.0