Programing requirement for Safety Alert System Version 01 I

Programing requirement for: Safety Alert System Version 01 I. Project and class name Create a new project name: yourfirst lastname program01 (you must include your name in the project name) Create a new class name: Safety Alert vo 1 II. Requirement 1. Input Prompt appropriate messages that asking use toenter: city name, season, temperature, and raining. Input validation: your program has to valid the user input and prompt specific message when user enter invalid input. Base on following validation: City name: only can be string of letters, not containing number. Maximum length is 20 Season: only can be either SUMMER or WINTER Temperature is in double Raining is in integer number if the program found an invalid input, prompt a specific message that tell which input is invalid and what is the correction format of that input should be, then STOP the program. That Page 2 of 4

Solution

package yourfirstname_lastname_project;

public class Safety_Alert_VO {

   private String cityName;
   private String Season;
   private double Temperature;
   private int raining;

   public Safety_Alert_VO() {
       this.cityName = null;
       this.Season = null;
       this.Temperature = 0;
       this.raining = 0;

   }

   public String getCityName() {
       return cityName;
   }

   public void setCityName(String cityName) {
       this.cityName = cityName;
   }

   public String getSeason() {
       return Season;
   }

   public void setSeason(String season) {
       Season = season;
   }

   public double getTemperature() {
       return Temperature;
   }

   public void setTemperature(double temperature) {
       Temperature = temperature;
   }

   public int getRaining() {
       return raining;
   }

   public void setRaining(int raining) {
       this.raining = raining;
   }

}

package yourfirstname_lastname_project;

import java.util.Scanner;

public class Demo {

   public static final int MIN_TEMP = 20;

   public static void main(String[] args) {
       final String winter = null;
       final String summer = null;

       Safety_Alert_VO alert = new Safety_Alert_VO();

       Scanner scanner = new Scanner(System.in);

       System.out
               .println(\"enter the customer name with less than 20 characters\");

       String cityName = scanner.next();
       System.out
               .println(\"enter the season winter/summer otherwise program will stop executing\");
       String Season = scanner.next();
       System.out.println(\"enter the temperature in no\'s\");

       double t = scanner.nextDouble();
       System.out.println(\"enter the rain density in no\'s\");
       int raining = scanner.nextInt();

       if (Season.trim().matches(\"summer\") || Season.trim().matches(\"winter\")) {
           System.out.println(\"you entered season value is correct\");
       } else {
           System.out.println(\"your entered season inputs are incorrect\");
           System.exit(0);
       }
       if (cityName.length() > 20) {
           System.out.println(\"you entered city name is too lengthy\");
           System.exit(0);
       }

       System.out.println(\"winter\");
       System.out.println(\"summer\");
       System.out.println(\"enter your choice\");

       String season = scanner.next();

       switch (season) {
       case \"winter\":
           if (t < 32 && raining > 0) {
               System.out.println(\"true\");
               break;
           }
           if (t < 5 || raining > 250) {
               System.out.println(\"yes,stay inside\");
               break;
           }
           if (t < -5 || raining > 500) {
               System.out.println(\"call for help , call 911 now\");
               break;
           } else
               System.out.println(\"nothing\");

           break;
       case \"summer\":
           final int CONST_MIN_TEMP = -20;

           if (t < CONST_MIN_TEMP) {
               System.out.println(\"next part\");
               break;
           } else
               System.out.println(\"weather is normal\");
           break;

       default:
           System.out.println(\"you choosen wrong option\");
           System.exit(0);

       }
   }

}

output

enter the customer name with less than 20 characters
david
enter the season winter/summer otherwise program will stop executing
winter
enter the temperature in no\'s
25
enter the rain density in no\'s
25
you entered season value is correct
1.winter
2.summer
enter your choice
winter
true

 Programing requirement for: Safety Alert System Version 01 I. Project and class name Create a new project name: yourfirst lastname program01 (you must include
 Programing requirement for: Safety Alert System Version 01 I. Project and class name Create a new project name: yourfirst lastname program01 (you must include
 Programing requirement for: Safety Alert System Version 01 I. Project and class name Create a new project name: yourfirst lastname program01 (you must include

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site