Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**********************JAVA Please***************** As a zookeeper, it is importa

ID: 3890193 • Letter: #

Question

**********************JAVA Please*****************
As a zookeeper, it is important to know the activities of the animals in your care and to monitor their living habitats. Create a monitoring system that does all of the following:
Asks a user if they want to monitor an animal, monitor a habitat, or exit
Displays a list of animal/habitat options (based on the previous selection) as read from either the animals or habitats file o Asks the user to enter one of the options
Displays the monitoring information by finding the appropriate section in the file
Separates sections by the category and selection (such as “Animal - Lion” or “Habitat - Penguin”)
Uses a dialog box to alert the zookeeper if the monitor detects something out of the normal range (These will be denoted in the files by a new line starting with *****. Do not display the asterisks in the dialog.)
Allows a user to return to the original options You are allowed to add extra animals, habitats, or alerts, but you may not remove the existing ones.

Specifically, the following critical elements must be addressed:

Process Documentation: Create process documentation to accompany your program that addresses all of the following elements:
A. Problem Statement/Scenario: Identify the program you plan to develop and analyze the scenario to determine necessary consideration for building your program.
B. Overall Process: Provide a short narrative that shows your progression from problem statement to breakdown to implementation strategies. In other words, describe the process you took to work from problem statement (your starting point) to the final product. Your process description should align to your end resulting program and include sufficient detail to show the step-by-step progress from your problem statement analysis.
C. Pseudocode: Break down the problem statement into programming terms through creation of pseudocode. The pseudocode should demonstrate your breakdown of the program from the problem statement into programming terms. Explain whether the pseudocode differs from the submitted program and document any differences and the reason for changes.
D. Methods and Classes: Your pseudocode reflects distinct methods and classes that will be called within the final program. If the pseudocode differs from the submitted program, document the differences and reason for changes.
E. Error Documentation: Accurately document major errors that you encountered while developing your program. F. Solution Documentation: Document how you solved the errors and what you learned from them.

Program: Your working program should include all of the specified requirements. The comments within your program will count toward the assessment of the documentation aspects of your submission.
A. Functionality 1. Input/Output: Your program reads input from the user and uses system output. 2. Control Structures: Your program utilizes appropriate control structures for program logic. 3. Libraries: Your program utilizes standard libraries to pull in predefined functionality. 4. Classes Breakdown: Your program is broken down into at least two appropriate classes. 5. Methods: Your program utilizes all included methods correctly within the classes. 6. Error Free: Your program has been debugged to minimize errors in the final product. (Your program will be run to determine functionality.)
B. Best Practices: These best practices should be evident within your working program and process documentation. 1. Formatting Best Practices: Provide program code that is easy to read and follows formatting best practices as defined by the industry, such as with indentation. 2. Documentation Best Practices: Include comments where needed within the program in appropriate detail for communicating purpose, function, and necessary information to other information technology (IT) professionals. 3. Coding Best Practices: Ensure your program supports clean code through descriptive variable names.

Explanation / Answer

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

import javax.swing.JOptionPane;

public class Chegg {

   public static void main(String[] args) throws IOException {
       // TODO Auto-generated method stub
       //JOptionPane.showMessageDialog(null, "Alter Zookeeper Abnormal state");
       //scanner class to read input from user
       Scanner sc=new Scanner(System.in);
       // buffered reader to read the file animal
       BufferedReader brA=new BufferedReader(new FileReader("g://files/animals.txt"));
       // bufferreader to read habitats
       BufferedReader brH=new BufferedReader(new FileReader("g://files/habitats.txt"));
       // to write to the file
       BufferedWriter bwA=new BufferedWriter(new FileWriter("g://files/animals.txt",true));
       BufferedWriter bwH=new BufferedWriter(new FileWriter("g://files/habitats.txt",true));

       // for option
       int option=0;
       // loop while user exists
       while(option!=3)
       {
           // reading animal and habitats
           brA=new BufferedReader(new FileReader("g://files/animals.txt"));
           brH=new BufferedReader(new FileReader("g://files/habitats.txt"));
           // prompting user
       System.out.println("Enter 1 to monitor Animals 2 for Habitats 3 to exit");
       option=sc.nextInt();
       // String to store details of animals and habitats
       String[] details=null;
       if(option==1)
       {
           //String for line
           String line;
        
           System.out.println("List of animals");
           // variables for operactions and check blank lines
           int op=0;
           int blankLine=0;
           int seperateSection=0;
           int index=-1;
           // loop through file
           while((line=brA.readLine())!=null)
           {
               seperateSection=0;
            
               // checking blank line
               if(line.equals(""))
               {
                   blankLine++;
                   if(blankLine==1)
                   {
                       // initializing array based on animals size
                       details=new String[op];
                   }
                   seperateSection=1;
                   // for array index
                   index++;
               }
               if(blankLine==0)
               {
                   // printing info from file
               op++;
               System.out.println("Enter "+op+" for");
               System.out.println(" "+line);
               }
               else if(blankLine!=0 && seperateSection==0)
               {
                   // loading list to array
                   details[index]=details[index]+" "+line;
               }
            
            
           }
           // closing stream
           brA.close();
           
           // printing the info
           int choose=sc.nextInt();
           System.out.println(details[choose-1]);
           // if abnoramal alert box
           if(details[choose-1].contains("****"))
           {
               // Alert box
               JOptionPane.showMessageDialog(null, "Alter Zookeeper Abnormal state");
           }
    
        
       }
       // For habitats same as above
       else if (option==2)
       {
String line;
        
           System.out.println("List of Habitats");
           int op=0;
           int blankLine=0;
           int seperateSection=0;
           int index=-1;
           while((line=brH.readLine())!=null)
           {
               seperateSection=0;
            
               if(line.equals(""))
               {
                   blankLine++;
                   if(blankLine==1)
                   {
                       details=new String[op];
                   }
                   seperateSection=1;
                   index++;
               }
               if(blankLine==0)
               {
               op++;
               System.out.println("Enter "+op+" for");
               System.out.println(" "+line);
               }
               else if(blankLine!=0 && seperateSection==0)
               {
                   details[index]=details[index]+" "+line;
               }
            
            
           }
           brH.close();
           int choose=sc.nextInt();
           System.out.println(details[choose-1]);
           if(details[choose-1].contains("****"))
           {
               JOptionPane.showMessageDialog(null, "Alter Zookeeper Abnormal state");
           }
       }
       // condition to exit
       else if(option==3)
           System.out.println("good bye");
       else
           System.out.println("Wrong option");
       }
       System.out.println("Enter 1 to Add Animal 2 to add Habitat 3 to no");
       int ch=sc.nextInt();
       if(ch==1)
       {
           bwA.newLine();
           System.out.println("Enter animal name:");
           bwA.write("Animal - "+sc.next());
           System.out.println("Enter keeper name");
           bwA.write(sc.next());
           System.out.println("Enter age:");
           bwA.write(sc.next());
           System.out.println("Enter health report");
           bwA.write(sc.next());
                 }
       if(ch==2)
       {
           bwH.newLine();
           System.out.println("Enter habitat name:");
           bwA.write("Habitat - "+sc.next());
           System.out.println("Enter keeper name");
           bwA.write(sc.next());
           System.out.println("Enter age:");
           bwA.write(sc.next());
           System.out.println("Enter health report");
           bwA.write(sc.next());         
       }    
   }

}