Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to create a java program for a ZooKeeper's Monitoring System. These are the instructions: Monitoring System As a zookeeper, it is

I am trying to create a java program for a ZooKeeper's Monitoring System. These are the instructions:

" Monitoring System 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."

I need to access either animal.txt or habitats.txt when user chooses those options off the first menu. if they choose option 2, the Animals menu, the text file needs to be accessed and ex. Details on lions in text needs to be written to option 1, and Details on tigers needs to be written to option 2. And so on. Then if they choose option 1 for Lions, then All that animals details need to be displayed off text file. if the information for that animal contains *****, then an alert needs to be displayed. I also would like user to press any key to go back to previous menu from the Animal info screen. A similar action needs to be taken for the Habitats menu.

Text files:

animals.txt

Details on lions Details on tigers Details on bears Details on giraffes

Animal - Lion Name: Leo Age: 5 *****Health concerns: Cut on left front paw Feeding schedule: Twice daily

Animal - Tiger Name: Maj Age: 15 Health concerns: None Feeding schedule: 3x daily

Animal - Bear Name: Baloo Age: 1 Health concerns: None *****Feeding schedule: None on record

Animal - Giraffe Name: Spots Age: 12 Health concerns: None Feeding schedule: Grazing

habitats.txt

Details on penguin habitat Details on bird house Details on aquarium

Habitat - Penguin Temperature: Freezing *****Food source: Fish in water running low Cleanliness: Passed

Habitat - Bird Temperature: Moderate Food source: Natural from environment Cleanliness: Passed

Habitat - Aquarium Temperature: Varies with output temperature Food source: Added daily *****Cleanliness: Needs cleaning from algae

My code so for: Lines 65 to 119 menuAnimals, lines 121 to 172 menuHabitats, lines 175 to 190 infoAnimals, lines 192 to 204 infoHabitats

1 import java.util.*;

2 import java.util.Scanner;

3 import java.lang.Object;

4 import java.io.FileInputStream;

5 import java.io.IOException;

6 /*

7 Zookeepers Monitoring System

8 Tracks the animals by breed, name of animal, age, heath concers, and feeding schedule

9 OR

10 Tracks the animal habitat type, tempature of habitat, food source, and cleanliness

11 OR

12 Exits program

13 @author Tara

14 */

15 public class TestMonitor {

16

17 public static void main(String[] args) throws IOException {

18

19 //Call openTextFiles class to open file animals.txt

20 //location of text file

21 String fileName = "C:\\Users\\tarad\\Google Drive\\9 IT-145 App

Development\\MonitoringSystem\\src\\animals.txt";

22 String fileName = "C:\\Users\\tarad\\Google Drive\\9 IT-145 App

Development\\MonitoringSystem\\src\\habitats.txt";

23

24

25 mainMenu();

26 }

27 //Method to start program at main menu to select: Monitor an Animal, Monitor a

Habitat, or Exit

28 public static void mainMenu() {

29 Scanner scnr = new Scanner(System.in);

30 int selection;

31

32 System.out.println(" Welcome to the Zookeeper's Monitoring System! ");

// Welcome

33

34 //Checks to see if input is valid

35 do {

36 System.out.println("Please Select Option: 1, 2, or 3! 1. to

Monitor an Animal 2. to Monitor a Habitat 3. to Exit ");

37 while (!scnr.hasNextInt()) {

38 System.out.println("Invalid Input! Not A Number");

39 System.out.println("Please Select Option: 1, 2, or 3! 1.

to Monitor an Animal 2. to Monitor a Habitat 3. to

Exit ");

40 scnr.next();

41 }

42 selection = scnr.nextInt(); //User inputs option

43 }

44 while (selection ==100);

45

46 switch (selection) {

47 case 1:

48 menuAnimals(); //Enter Monitor an Animal menu

49 break;

50 case 2:

51 menuHabitats (); //Enter Monitor a Habitat menu

52 break;

53 case 3:

54 System.out.println("Goodbye");

55 System.exit(0); //Exits program

56 break;

57 default:

58 System.out.println("Invalid Input! Not A Valid Menu Option!"

);

59 mainMenu();

60 break;

61 }

62 //End mainMenu

63 }

64

65 //Method to open Monitor an Animal menu

66 public static void menuAnimals () {

67 Scanner scnr = new Scanner(System.in);

68 int selection;

69

70 System.out.println("Monitor an Animal");

71

72 //Checks to see if input is valid

73 do {

74 System.out.println("Please Select Option: 1, 2, 3, 4, 5, 6 or 7!

1. Details on lions 2. Details on tigers "

75 + " 3. Details on bears 4. "

76 + "Details on giraffes 5. Go back to Main Menu 6.

Monitor a Habitat 7. to Exit");

77 while (!scnr.hasNextInt()) {

78 System.out.println("Invalid Input! Not A Number");

79 System.out.println("Please Select Option: 1, 2, 3, 4, 5, 6

or 7! 1. Details on lions 2. Details on tigers "

80 + " 3. Details on bears 4. "

81 + "Details on giraffes 5. Go back to Main Menu 6.

Monitor a Habitat 7. to Exit");

82 scnr.next();

83 }

84 selection = scnr.nextInt(); //User inputs option

85 }

86 while (selection == 100);

87

88 switch (selection) {

89 case 1:

90 System.out.println("Animal - Lion");

91 break;

92 case 2:

93 System.out.println("Animal - Tiger");

94 break;

95 case 3:

96 System.out.println("Animal - Bear");

97 break;

98 case 4:

99 System.out.println("Animal - Giraffee");

100 break;

101 case 5:

102 System.out.println("Go back to Main Menu");

103 mainMenu();

104 break;

105 case 6:

106 System.out.println("Monitor a Habitat");

107 menuHabitats();

108 break;

109 case 7:

110 System.out.println("Goodbye");

111 System.exit(0);

112 break;

113 default:

114 System.out.println("Invalid Input! Not A Valid Menu Option!"

);

115 menuAnimals();

116 break;

117 }

118 //End menuAnimals

119 }

120

121 //Method to open Monitor an Habitat menu

122 public static void menuHabitats () {

123 Scanner scnr = new Scanner(System.in);

124 int selection;

125

126 System.out.println("Monitor a Habitat");

127

128 //Checks to see if input is valid

129 do {

130 System.out.println("Please Select Option: 1, 2, 3, 4, 5 or 6! 1.

Details on penguin habitat"

131 + " 2. Details on bird house 3. Details on aquarium

4. "

132 + "Go back to Main Menu 5. Monitor an Animal 6. to Exit"

);

133 while (!scnr.hasNextInt()) {

134 System.out.println("Invalid Input! Not A Number");

135 System.out.println("Please Select Option: 1, 2, 3, 4, 5 or

6! 1. Details on penguin habitat"

136 + " 2. Details on bird house 3. Details on aquarium

4. "

137 + "Go back to Main Menu 5. Monitor an Animal 6. to Exit"

);

138 scnr.next();

139 }

140 selection = scnr.nextInt(); //User inputs option

141 }

142 while (selection == 100);

143

144 switch (selection) {

145 case 1:

146 System.out.println("Habitat - Penguin");

147 break;

148 case 2:

149 System.out.println("Habitat - Bird");

150 break;

151 case 3:

152 System.out.println("Habitat - Aquarium");

153 break;

154 case 4:

155 System.out.println("Go back to Main Menu");

156 mainMenu();

157 break;

158 case 5:

159 System.out.println("Monitor an Animal");

160 menuAnimals();

161 break;

162 case 6:

163 System.out.println("Goodbye");

164 System.exit(0);

165 break;

166 default:

167 System.out.println("Invalid Input! Not A Valid Menu Option!"

);

168 menuHabitats();

169 break;

170 }

171 //End menuHabitats

172 }

173

174

175 //Information about each animal

176 public static void infoAnimals() {

177 String typeAnimal;

178 String nameAnimal;

179 String ageAnimal;

180 String healthAnimal;

181 String feedAnimal;

182

183 System.out.println("Animal - " + typeAnimal);

184 System.out.println("Name: " + nameAnimal);

185 System.out.println("Age: " + ageAnimal);

186 System.out.println("Health concerns: " + healthAnimal);

187 System.out.println("Feeding schedule: " + feedAnimal);

188

189 //End infoAnimals

190 }

191

192 //Information about each habitat

193 public static void infoHabitats() {

194 String typeHabitat;

195 String tempHabitat;

196 String foodHabitat;

197 String cleanHabitat;

198

199 System.out.println("Habitat - " + typeHabitat);

200 System.out.println("Temperature: " + tempHabitat)

201 System.out.println("Food source: " + foodHabitat);

202 System.out.println("Cleanliness: " + cleanHabitat);

203 //End infoHabitats

204 }

205

206

207

208 }

209

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions