package com.samovich.cop2800.chapter5.assignment;

import javax.swing.JOptionPane;

/**
 * Filename PetAdvice.java
 * Created by Valery Samovich
 * Written on 5/31/2016
 */
public class PetAdvice {

    public static void main(String[] args) {

        // declare variables
        String dwellingType;
        int dwellingNumber;

        // prompt the user to accept value
        dwellingType = JOptionPane.showInputDialog(
                null,
                "Enter 1 (apartment), 2 (house), 3 (dorm):",
                "Dwelling Type",
                JOptionPane.QUESTION_MESSAGE);

        // convert string to an number
        dwellingNumber = Integer.parseInt(dwellingType);

        // test if entered value is valid
        if (dwellingNumber < 1 || dwellingNumber > 3) {
            // display error message
            JOptionPane.showMessageDialog(
                    null,
                    "The value for dwelling type must be 1 (apartment), 2 (house), or 3 (dorm)",
                    "Dwelling Type Error",
                    JOptionPane.ERROR_MESSAGE);
            // stop the application
            System.exit(0);
        }

        // print the entered value
        System.out.println(dwellingNumber);
    }
}

@@ -234,24 +234,579 @@
 %5B%5D args) %7B%0A%0A
+        // declare variables%0A        int validDwellingNumber;%0A        int validHoursPerWeek;%0A%0A        // get valid values%0A        validDwellingNumber = getDwellingNumber();%0A        validHoursPerWeek = getHoursPerWeek();%0A%0A        // print the entered value%0A        System.out.println(validDwellingNumber);%0A        System.out.println(validHoursPerWeek);%0A    %7D%0A%0A    /**%0A     * Method design to process user input and return type of dwelling as a%0A     * number if it's valid.%0A     * @return dwellingNumber%0A     */%0A    private static int getDwellingNumber() %7B%0A
         // d
@@ -914,20 +914,36 @@
  to 
-accept value
+enter the value for dwelling
 %0A   
@@ -1325,14 +1325,38 @@
 ber 
-%3C 1 %7C%7C
+!= 1 && dwellingNumber != 2 &&
  dwe
@@ -1371,9 +1371,10 @@
 ber 
-%3E
+!=
  3) 
@@ -1538,16 +1538,49 @@
 must be 
+%22 +%0A                            %22
 1 (apart
@@ -1780,87 +1780,1280 @@
   %7D%0A
+        return dwellingNumber;
 %0A    
+%7D%0A%0A
     /
-/ print the
+**%0A     * Method design to process user input for hours per week and return value%0A     * as number if it's valid.%0A     * @return hoursPerWeekAsNumber%0A     */%0A    private static int getHoursPerWeek()%7B%0A        // declare variables%0A        String hoursPerWeek;%0A        int hoursPerWeekAsNumber;%0A%0A        // prompt the user to
  enter
+ th
 e
-d
  value
-%0A        System.out.println(dwelling
+ for hours%0A        hoursPerWeek = JOptionPane.showInputDialog(%0A                null,%0A                %22Enter the number of hours per week you are home:%22,%0A                %22Hours at Home%22,%0A                JOptionPane.QUESTION_MESSAGE);%0A%0A        // convert string to an number%0A        hoursPerWeekAsNumber = Integer.parseInt(hoursPerWeek);%0A%0A        // test if entered value is valid%0A        if (hoursPerWeekAsNumber %3C 0 %7C%7C hoursPerWeekAsNumber %3E 168) %7B%0A            // display error message%0A            JOptionPane.showMessageDialog(%0A                    null,%0A                    %22The number of hours per week you are home must be %22 +%0A                            %22between 0 and 168 inclusive%22,%0A                    %22Hours at Home Error%22,%0A                    JOptionPane.ERROR_MESSAGE);%0A            // stop the application%0A            System.exit(0);%0A        %7D%0A        return hoursPerWeekAs
 Number
-)
 ;
+%0A
 %0A   

Add method to get value for hours per week