Question
JAVA Pseudocode: Break down the problem statement into programming terms through creation of pseudocode. (The pseudocode should demonstrate your breakdown of the program from the
JAVA 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.)
My Code:
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 Monitoringsystem { public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); BufferedReader brA=new BufferedReader(new FileReader("g://files/animals.txt")); BufferedReader brH=new BufferedReader(new FileReader("g://files/habitats.txt")); BufferedWriter bwA=new BufferedWriter(new FileWriter("g://files/animals.txt",true)); BufferedWriter bwH=new BufferedWriter(new FileWriter("g://files/habitats.txt",true)); int option=0; while(option!=3) { brA=new BufferedReader(new FileReader("g://files/animals.txt")); brH=new BufferedReader(new FileReader("g://files/habitats.txt")); System.out.println("Enter 1 to monitor Animals 2 for Habitats 3 to exit"); option=sc.nextInt(); String[] details=null; if(option==1) { String line; System.out.println("List of animals"); int op=0; int blankLine=0; int seperateSection=0; int index=-1; while((line=brA.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;
}
}
brA.close();
int choose=sc.nextInt();
System.out.println(details[choose-1]);
if(details[choose-1].contains("****"))
{
JOptionPane.showMessageDialog(null, "Alter Zookeeper Abnormal state");
}
}
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");
}
}
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());
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started