//Bunch-O-Review from Ferworn. Oct 2011 // kind of implements boolean values to work like in the C programming // language where 0==false and all other values are true; import javax.swing.JOptionPane; public class MidReviewDriver { public static void main(String[] args) { String input; // make some objects MidReview booltruth = new MidReview(true); MidReview inttruth = new MidReview(1); // input a number input = JOptionPane.showInputDialog ("Enter an integer between 0 and 2"); int num = Integer.parseInt(input); // do some "selection" // work an object's methods System.out.print("The truth is "); if(booltruth.notter()) System.out.print("not"); System.out.println(" out there."); booltruth.makenot(); System.out.print("The truth is "); if(booltruth.notter()) System.out.print("not"); System.out.println(" out there."); if(num == 0) System.out.println("input was zero"); else if(num == 1) System.out.println("input was one"); else if(num==2) System.out.println("input was two"); else System.out.println("wrong input!!!"); switch(num) { case 0: System.out.println("input was zero"); break; case 1: System.out.println("input was one"); break; case 2: System.out.println("input was two"); break; default: System.out.println("wrong input!!!"); } // Let's do some iteration System.out.println("zeroth time through while loop"); int counter = 0; while(counter < num) { System.out.println("I'm counting!"); counter++; } counter = 0; System.out.println("first time through while loop"); while(counter++ < num) System.out.println("I'm counting!"); System.out.println("second time through wile loop"); counter = 0; while(++counter < num) System.out.println("I'm counting!"); System.out.println("third time through wile loop"); counter = 0; do{ counter++; System.out.println("I'm counting!"); } while(counter < num); System.out.println("fourth time through wile loop"); counter = 0; for(;counter < num; counter++) System.out.println("I'm counting!"); } }