1 /* 2 * Exploring and playing with arithmetic expressions while solving simple problems, including Crypto. 3 */ 4 5 package expressions; 6 7 public class ExpressionsThing { 8 public static void main(String[] args) { 9 //three expressions (one, two, and three) intended to compute the perimeter of a circle of radius 5 (3.14 as approximation of Pi) 10 double one = 3.14 * 5 + 5; // This is the incorrect expression, it is not fully parenthesized 11 System.out.println("one = " + one); 12 13 double two = 3.14 * (5 + 5); //correct 14 System.out.println("two = " + two); 15 16 double three = (3.14 * (5 + 5)); //correct 17 System.out.println("three = " + three); 18 19 int four = (5 * 6); 20 System.out.println("four = " + four); 21 22 double five = (55.0 / 2.0); 23 System.out.println("five = " + five); 24 25 double six = (65.0 / 3.0); 26 System.out.println("six = " + six); 27 28 double seven = (five + six); 29 System.out.println("seven = " + seven); 30 31 double eight = (3.14 * (11.3 * 11.3)); //Area = (3.14 * (R * R)) 32 System.out.println("eight = " + eight); 33 34 double nine = (27.7 * 27.7); //Area = (S x S) 35 System.out.println("nine = " + nine); 36 37 double ten = ((eight + nine) / 2.0); //average areas of circle and square w/ circle radius 11.3 and square side 27.7 38 System.out.println("ten = " + ten); 39 40 double eleven = (.17 * 243.5); //17% of 243.5 41 System.out.println("eleven = " + eleven); 42 43 //Crypto problem solutions 44 int twelve = (3/3); //Sources: 3, 3 | Goal: 1 45 System.out.println("twelve = " + twelve); 46 47 int thirteen = ((7 - 4) - 2);//Sources: 4, 7, 2 | Goal: 1 48 System.out.println("thirteen = " + thirteen); 49 50 int fourteen = ((9+7)/(1+3)); //Sources: 1, 3, 7, 9 | Goal: 4 51 System.out.println("fourteen = " + fourteen); 52 53 int fifteen = (((2 + 2) * (4 + 6)) / 8); //Sources: 2, 2, 4, 6, 8 | Goal: 5 54 System.out.println("fifteen = " + fifteen); 55 } 56 } 57