// 11/27/2017 import java.util.Scanner; public class Misc { /** * 1. conditional operator * 2. method composition */ public static void main(String[] args) { // operator that is used to assign a value to a variable based // on a condition double taxes; int salary=150000; /* if (salary>100000) taxes=.2; else taxes=.15; */ taxes = salary>100000 ? .2 : .15; System.out.printf("Taxes are %.2f%%\n", taxes*100); int a=10, b=34; int maximum = findMax(a,b); // say I want c to get the max(a,b) times 2 int c = maximum*2; // same thing, doing it in a shorter way // uses return value of call in an expression c = findMax(a,b) * 2; int d=900; // method composition -- uses return value as a parameter to a method call c = findMax(findMax(a,b),d); } public static int findMax(int x, int y) { return x>y ? x : y; } public static boolean isLarger(int x, int y) { // this method returns true if x>y, false otherwise return x>y ? true : false; } }