Question: Please help me with this lab question, thanks ***We have to use this format** public class Calendar{ public static boolean addEvent(String [ ] calendar, String
Please help me with this lab question, thanks

***We have to use this format** public class Calendar{ public static boolean addEvent(String [ ] calendar, String event, int date){ return false; // replace this with your code } // bug in printCalendar fixed 7/4/2014 LS public static void printCalendar(String [ ] calendar){ for (int d = 1; d
**This is the IO.java it says to download**
import java.io.*; public class IO { private static BufferedReader kb = new BufferedReader(new InputStreamReader(System.in)); public static String readString() { while (true) { try { return kb.readLine(); } catch (IOException e) { // should never happen } } } public static int readInt() { while (true) { try { String s = kb.readLine(); return Integer.parseInt(s); } catch (NumberFormatException e) { System.out.print("That is not an integer. Enter again: "); } catch (IOException e) { // should never happen } } } public static double readDouble() { while (true) { try { String s = kb.readLine(); return Double.parseDouble(s); } catch (NumberFormatException e) { System.out.print("That is not a number. Enter again: "); } catch (IOException e) { // should never happen } } } public static char readChar() { String s = null; try { s = kb.readLine(); } catch (IOException e) { // should never happen } while (s.length() != 1) { System.out.print("That is not a single character. Enter again: "); try { s = kb.readLine(); } catch (IOException e) { // should never happen } } return s.charAt(0); } public static boolean readBoolean() { String s = null; while (true) { try { s = kb.readLine(); } catch (IOException e) { // should never happen } if (s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("y") || s.equalsIgnoreCase("true") || s.equalsIgnoreCase("t")) { return true; } else if (s.equalsIgnoreCase("no") || s.equalsIgnoreCase("n") || s.equalsIgnoreCase("false") || s.equalsIgnoreCase("f")) { return false; } else { System.out.print("Enter \"yes\" or \"no\": "); } } } public static void outputStringAnswer(String s) { System.out.println("RESULT: \"" + s + "\""); } public static void outputIntAnswer(int i) { System.out.println("RESULT: " + i); } public static void outputDoubleAnswer(double d) { System.out.println("RESULT: " + d); } public static void outputCharAnswer(char c) { System.out.println("RESULT: '" + c + "'"); } public static void outputBooleanAnswer(boolean b) { System.out.println("RESULT: " + b); } public static void reportBadInput() { System.out.println("User entered bad input."); } }
1. Download Calendarjava, from Sakai > Resources > Labs > Lab5. Also download IO java, if you don't already have it in the folder where you put Calendar java 2. Calendar.java is a program that implements a simplified event calendar. o The calendar will be for one month only o We will assume every month has 31 days. will assume every month has 31 days We will record at most one event per day 3. An event will be represented by a String. 4. A calendar will be represented by an array of 32 Strings, with the String at index d of the array representing the event, if any, for the date d. E.g., index 5 holds the event for the fifth of the month. Index 0 of the array will not be used. If there is no event recorded for a date, the corresponding element of the array will be nu The method addEvent takes 3 arguments: a calendar (i.e., an array of strings), an event (i.e., a String), and a date (i.e., an int). If there is already an event scheduled for the date, addEvent does not change the array, and returns false. If there is no event scheduled for the date yet, addEvent stores the event in index date of the calendar array and returns true. If the date is erroneous, i.e. less than 1 or more that 31, addEvent just returns false. Your first task for this Lab is to replace the line with the comment "/ replace this with your code" so that addEvent does those things The method printCalendar takes one argument, a calendar (i.e. an array of Strings), and prints it. printCalendar is already written for you The method main calls the other methods in order to test them. Your second task for this Lab is to replace the comment "/I add your test calls here" with your own calls to addEvent and to printCalendar in order to test all aspects of addEvent
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
