Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need C++ help to understand the steps taken to build a Struct record array the following specifications to build the program with the states file.

Need C++ help to understand the steps taken to build a Struct record array the following specifications to build the program with the states file. image text in transcribed

image text in transcribed

Records in the States.txt file contain two fields that are loaded into component fields of a struct array. #include include include using namespace std; struct stateRecord Each state records contains a two-character state postal code and the full name of the state or district. These fields are loaded into two separate parallel arrays. The relative position of a state code in one array is the same as the corresponding state name in the other array Statestt-Noteped stringstateCode; string stateName; AK Alaska AL Alabama AR Arkansas AZ Arizona CA California Co Colorado CT Connecticut DC District of Colunbia DE Delavare int main() stateRecord stateInfo[60]; string codeInput int int cnt 8; pos; VA Virginia ifstream stateInput; stateInput.open("States.txt"; if (IstateInput) VT Vermont WA Hashington NI Wisconsin W West_Virginie WY Wyoming cout stateInfo[cnt].statecode stateInfo[cnt].stateName; read first record while (IstateInput.eof()) cnt++; /l/ count records stateInput stateInfo[cnt].stateCode >> stateInfo[cnt].stateName; / read next record stateInput.close(); cout codeInput; while (codeInput "Q"&8 codeInput 1- "q") // close file after load /l display count // state code prompt // input state code // continue until Quit pos = while (code1nput != stateInfo(pos].statecode && pos > codeInput; // state code prompt / input state code After the loop ends, display the state label if the code has been matched. Otherwise, show that no match was found. nmming read Records in the States.txt file contain two fields that are loaded into component fields of a struct array. #include include include using namespace std; struct stateRecord Each state records contains a two-character state postal code and the full name of the state or district. These fields are loaded into two separate parallel arrays. The relative position of a state code in one array is the same as the corresponding state name in the other array Statestt-Noteped stringstateCode; string stateName; AK Alaska AL Alabama AR Arkansas AZ Arizona CA California Co Colorado CT Connecticut DC District of Colunbia DE Delavare int main() stateRecord stateInfo[60]; string codeInput int int cnt 8; pos; VA Virginia ifstream stateInput; stateInput.open("States.txt"; if (IstateInput) VT Vermont WA Hashington NI Wisconsin W West_Virginie WY Wyoming cout stateInfo[cnt].statecode stateInfo[cnt].stateName; read first record while (IstateInput.eof()) cnt++; /l/ count records stateInput stateInfo[cnt].stateCode >> stateInfo[cnt].stateName; / read next record stateInput.close(); cout codeInput; while (codeInput "Q"&8 codeInput 1- "q") // close file after load /l display count // state code prompt // input state code // continue until Quit pos = while (code1nput != stateInfo(pos].statecode && pos > codeInput; // state code prompt / input state code After the loop ends, display the state label if the code has been matched. Otherwise, show that no match was found. nmming read

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_2

Step: 3

blur-text-image_3

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

2. Give ample praise for good answers.

Answered: 1 week ago