Drill 4

PHOTO EMBED

Sun Feb 12 2023 00:41:19 GMT+0000 (Coordinated Universal Time)

Saved by @Achilles_17

import tester.*;
class Drill4{
    String phaseOfWater(int x){
    if (x >= 100){
        return "vapor";
    }
    if (x < 100 && x > 0){
        return "liquid";
    }
    if (x <= 0){
        return "solid";
    }
    return "invalid";
    }
    int MaxDifference(int t, int y, int z){
        int ty = Math.abs(t - y);
        int tz = Math.abs(t - z);
        int yz = Math.abs(y - z);
        if (ty > tz && ty > yz){
            return ty;
        }
        if (tz > ty && tz > yz){
            return tz;
        }
        else{
            return yz;
        }
    }
    double ringArea(double r1, double r2){
        double area1 = (Math.PI * (r1 * r1));
        double area2 = (Math.PI * (r2 * r2));
        return area2 - area1;
    }

    void testphaseOfWater(Tester t){
        t.checkExpect(phaseOfWater(77),"liquid");
        t.checkExpect(phaseOfWater(100),"vapor");
        t.checkExpect(phaseOfWater(-123),"solid");
    }
    void testMaxDifference(Tester t){
        t.checkExpect(MaxDifference(7, 15, 21), 14);
        t.checkExpect(MaxDifference(1,2,3),2);
        t.checkExpect(MaxDifference(99, 201, 303), 204);
    }
    void testringArea(Tester t){
        t.checkExpect(ringArea(7.0, 9.0), 100.53096491487338);
        t.checkExpect(ringArea(8.0, 9.0), 53.40707511102647);
        t.checkExpect(ringArea(5.0, 9.0), 175.9291886010284);
    }
    }
content_copyCOPY