// Bob Myers // // See if you can guess which calls in main() the compiler will allow // and which ones cause syntax errors. (Then compile to check). // (Only the header line of each method is needed to figure this out) // // The methods are written below the main() method. import java.util.Random; public class Syntax { private static Random r = new Random(); public static void main(String[] args) { char c1, c2; double d1, d2, d3; int i1, i2; // are these calls LEGAL or ILLEGAL, syntactically? // (put yourself in the compiler's shoes) average(d1, d2); c1 = average(d1, d2); d1 = average(d2, d3); d3 = average(d2, i2); getACharacter; c1 = getACharacter; c2 = getACharacter(); i1 = getACharacter(); printValues(int,double); i2 = printValues(i1, d1); printValues(i2, d2); printValues(d1, i2); } public static double average(double x, double y) { return (x + y) / 2.0; } public static char getACharacter() { String alphabet = "abcdefghijklmnopqrstuvwxyz"; return alphabet.charAt(r.nextInt(26)); } public static void printValues(int count, double amount) { System.out.println("Here are the two values:"); System.out.println("------------------------------------------"); System.out.println("\t" + count + '\t' + amount); } }