Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ An automatic animal monitoring device sits in the african savannah monitoring all the animals that pass within range. Throughout the day it creates

Using C++

An automatic animal monitoring device sits in the african savannah monitoring all the animals that pass within range. Throughout the day it creates a large text file that records all of its observations. At the end of the day that file is uploaded to a research base and analysed.

The file has one line for each animal observed. Each line has the same format: first the time (in 24 hour form), then the species of the animal (a single word, using only lower case letters), then the direction it was heading (N, S, E, or W), then an estimate of its weight (in pounds), and finally an estimate of its speed (in miles per hour). Here is a sample from a typical file...

0530 gorilla E 441.3 2.9

0531 gorilla E 338.0 2.8

0531 gorilla E 127.5 2.8

0540 zebra W 1107.0 11.0

0542 lion W 510.3 15.0

0551 penguin S 5.1 45.0

0551 gorilla W 338.0 2.1

It seems to show a family of gorillas strolling towards the rising sun, then shortly later a zebra chased by a lion going in the opposite direction, and then a small penguin flying south and one of the gorillas coming back. The name of the file is animals.txt. Write a function that processes this file and does the following things:

+ It must create a new file called gorillas.txt containing all the records of gorilla observations.

+ It must calculate the average weight of all the lions observed.

+ It must note the speed of the slowest gorilla seen heading east in the morning (time between 0000 and 1200).

So if the sample data given above were the whole file, your function would create a gorillas.txt file containing:

0530 gorilla E 441.3 2.9

0531 gorilla E 338.0 2.8

0531 gorilla E 127.5 2.8

0551 gorilla W 338.0 2.1

And it would print for the user to see: Average lion weight 510.3 pounds Slowest east-bound morning gorilla 2.8 mph

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

Recommended Textbook for

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

Students also viewed these Databases questions

Question

Tool (SIP): Go back and rework your school improvement plan so that

Answered: 1 week ago