Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Help Make an array of structs (sounds like a project idea). You are going to create an array of basicStruct of size 10. You

C++ Help

Make an array of structs (sounds like a project idea).

You are going to create an array of basicStruct of size 10. You will then make a function with the following signature:

You are going to write one function called:

void readData( string input, string output ); 

declare it in:

lab9.h 

I would make it the last declaration in the file. So have the struct first, then this one.

This function will read data and store it in the array. The array this time is an array of the basicStruct type instead of ints, so our input will a string and a double. You are to read the string and the double. If there is space in the array, then store the string and the double in the array at the next available location in the array.

Sample Input

Dave 10.3 Kelly 15.2 Sue 45.5 Michael 36.5 Matt 23.1 Molly 7.25 

Sample Output

You should not initialize your array and then print out ?'s Just print out the values in the array.

I used ? above to represent the value that I don't know. Since those locations didn't get a value C++ doesn't guarantee any value. I will check that the good values are set.

Index Name Number 0 Dave 10.3 1 Kelly 15.2 2 Sue 45.5 3 Michael 36.5 4 Matt 23.1 5 Molly 7.25 6 ? ? 7 ? ? 8 ? ? 9 ? ? 

Testing

It's always a good idea to test your code. I'll provide a real simple main you can use.

#include  #include "lab9.h" using std::cout; using std::cin; using std::endl; int main() { readData( "input.txt", "output.txt"); } 

The output here will depend on what you type in the file. I would enter some data and see what happens.

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

Students also viewed these Databases questions

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago