Respuesta :
Answer:
The solution code is written in c++
- #include <iostream>
- using namespace std;
- struct Frog {
- Â string Name;
- Â int Age;
- Â float LegLength;
- };
- int main ()
- {
- Â Frog frog_test;
- Â frog_test.Name = "Todd Jones";
- Â frog_test.Age = 12;
- Â frog_test.LegLength = 12.34;
- Â
- Â int num;
- Â cout<<"Enter number of frogs: ";
- Â cin>>num;
- Â
- Â Frog frog[num];
- Â
- Â int i;
- Â for(i = 0; i < num; i++){
- Â Â Â
- Â Â Â cout<<"What is the name of Frog "<< i + 1 <<" ?";
- Â Â Â cin>> frog[i].Name;
- Â Â Â
- Â Â Â cout<<"What is the age of Frog "<< i + 1 <<" ?";
- Â Â Â cin>> frog[i].Age;
- Â Â Â
- Â Â Â cout<<"What is the leg length of Frog "<< i + 1 <<" ?";
- Â Â Â cin>> frog[i].LegLength;
- Â }
- }
Explanation:
Firstly, define a Frog struct as required by the question (Line 4 - 8).
We create a test Frog struct (Line 12 - 15).
If we run the code up to this point, we shall see a Frog struct has been build without error.
Next, prompt user to input number of frogs desired (Line 17 -19).
Use the input number to declare a frog array (Line 21).
Next, we can use a for loop to repeatedly ask for input info of each frog in the array (Line 23- 34).
At last, we shall create num elements of Frog struct in the array.