/* * CS5App.java * * Homework # 3 * Problem # 2 * * Pair programming problem. If you're working in a pair, be * sure to include both names and please submit just one copy * under either one of the names.... * * Name(s): * Date: * Time spent: * * Comments! (A brief reflection on the programming teamwork * is required of problems done by teams of two.) * * */ import java.awt.*; class CS5App { public static void main(String[] args) { // // print the menu // H.pl("Welcome to the Moth Menu!"); H.pl(" 0) Discover the # of moths in my collection"); H.pl(" 1) Report the number of moths in your collection"); H.p("\nWhat is your choice? "); int uc = H.ni(); // uc is the user's choice switch (uc) { case 1: // asking for the user's # of moths { H.p("\nHow many moths do you have? "); int yourMoths = H.ni(); H.pl("\nWow... you have " + yourMoths + " moths?!"); } case 0: // reporting the computer's # of moths { int numMoths = H.randInt(1,1000000); H.pl("\nI have " + numMoths + " moths!"); break; } default: // the user typed an incorrect choice { H.pl("\nWhoa! That choice, " + uc + ", bugs me."); } } H.pl(); } // end of main }