Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Having trouble understanding this C++ programming concept. Totally confused how to separate string from integer to find highest and lowest and then display the Bird

Having trouble understanding this C++ programming concept. Totally confused how to separate string from integer to find highest and lowest and then display the Bird species assigned to that number. Maybe I'm not supposed to separate strings and read the whole line? Not sure, please help writing this code.

image text in transcribed

Data to read from file

Snow Goose:1 Cackling Goose:8 Canada Goose:12651 Trumpeter Swan:1 Gadwall:11 American Black Duck:7 Mallard:1733 Northern Shoveler:21 Green-winged Teal:1 Ring-necked Duck:2 Bufflehead:3 Common Goldeneye:153 Hooded Merganser:44 Common Merganser:157 Ruddy Duck:3 Ring-necked Pheasant:4 Wild Turkey:4 Double-crested Cormorant:1 Great Blue Heron (Blue form):32 Great Egret:1 Northern Harrier:19 Sharp-shinned Hawk:1 Cooper's Hawk:21 Bald Eagle:12 Red-tailed Hawk:92 Virginia Rail:1 American Coot:1 Sandhill Crane:98 Wilson's Snipe:2 Ring-billed Gull:99 Herring Gull:62 Rock Pigeon (Feral Pigeon):432 Mourning Dove:763 Eastern Screech-Owl:1 Great Horned Owl:13 Short-eared Owl:1 Northern Saw-whet Owl:3 Belted Kingfisher:28 Red-bellied Woodpecker:211 Downy Woodpecker:272 Hairy Woodpecker:85 Northern Flicker:23 Pileated Woodpecker:2 American Kestrel:13 Peregrine Falcon:2 Northern Shrike:4 Blue Jay:138 American Crow:194 Horned Lark:25 Black-capped Chickadee:663 Red-breasted Nuthatch:40 White-breasted Nuthatch:282 Brown Creeper:36 Winter Wren:18 Carolina Wren:12 Golden-crowned Kinglet:7 Eastern Bluebird:18 Hermit Thrush:9 American Robin:1097 European Starling:2972 Cedar Waxwing:380 Lapland Longspur:1 Yellow-rumped Warbler (Myrtle):29 American Tree Sparrow:389 Fox Sparrow:13 Dark-eyed Junco:728 White-crowned Sparrow:7 White-throated Sparrow:72 Savannah Sparrow:3 Song Sparrow:74 Swamp Sparrow:28 Northern Cardinal:536 Red-winged Blackbird:14 Rusty Blackbird:20 Common Grackle:1 House Finch:464 Pine Siskin:327 American Goldfinch:419 House Sparrow:994
b) Prompt and read a data filename from the user. If the file cannot be successfully opened, display an error message to the user and exit with an error code of -2. Each line of the data file includes the bird species name and the count separated by a colon; there can be any number of lines per file. Read the file contents into arrays/vectors for subsequent processing. File read and array/vector population should only occur once for the entire program run. Close the file when reading is complete. c) Use a modular approach in your program: o Do not use global variables; use local variables, parameters/arguments, and return values to transfer data between functions. Use the main function as the controlling function to start the program, create variables, call functions with appropriate arguments, display the output, and end the program. C++ Language Programming o Create separate functions to perform individual tasks; the main function should not include all program logic. At a minimum the program should include separate functions for the following (no display done in the functions; parameters and return values used by main function): populating arrays/vectors with data from file, determining bird species with the highest count, and determining the bird species with the lowest count d) Display the processing results in a table format as follows: . Command Prompt F:\CIS2541\L6>CBCounts.exe Enter the name of file containing bird count data: SampleCounts.txt Bird Species Count Highest Ring-billed Gull Lowest American Coot Exiting Christmas Bird Count program... F:\CIS2541\L6). 99 1

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions