Exam 1 Solutions
//Question 1 class Question1 { public static void main(String []args) { System.out.println("Question #1); } } //Question 2 public satatic int square(int number) { return number*number; } //Question 3 public static double cylinderVolume(double length, double radius) { return length*radius*radius*3.14; } //Question 4 if(walletAmount < giftAmout) { System.out.println("Too expensive"); } //Question 5 if(printWarning) { System.out.println("Option not availible"); } //Question 6 if (heightInInches > maximumAllowed) { System.out.println("You are too tall for the kiddie area"); } else { System.out.println("Enter the ride"); } //Question 7 for(int n=1; n <=10; n++) { if(n%2==0){ System.out.println(n); } } //Question 8 int n = 29; while (n > 10){ if(n%2 == 1) { System.out.println(n); } n--; } //Question 9 for (int n= lowerBound; n <= upperBound; n++) { if (n%5 == 0) { System.out.println(n); } } //Question 10 switch (choice) { case 'G': System.out.println("Greg"); break; case 'M': System.out.println("Michael"); break; case 'K': System.out.println("Kesden"); break; default: break; }