Question: in Java Precipitation enum * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools |
in Java

Precipitation enum * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
/** * * @author kerlin */ public enum Precipitation {None,Rain,Snow}
Problem 1: Precipitation I have created a Precipitation enum for you to use. Write a simple driver program with 2 methods. The main() method should: Ask the user what type of Precipitation is occurring right now. Send that data to a method called weather) If the method generates an exception, at the very least print out the message generated by the Exception The weather) method should: Take in an input String. Check the input String against the acceptable Precipitation values in the enum If the input String doesn't match an acceptable enum value, throw a InvalidPrecipitation Exception exception with the message "Exception: That is NOT a valid precipitation!" If the input String matches an acceptable Precipitation value, print the correct message (Precipitation value in bold, String message follows: None: "Enjoy dry sunny day! Rain: "Might be a good day to collect water?" Snow: "I hope you have a shovel ready!" Grading Breakdown: 10-Correctly creating the Exception Class 10 Correctly generating/throwing the Exception 10-Correctly trying and catching the Exception 10 - -Correctly working with enum
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
