Quote:
QUOTE
Create a program that includes the following:
A structure called ‘planet’ that includes a name, a distance from the sun and the diameter of the planet.
This I understand.
Code:
CODE
struct Planet {
string planName;
double planDistSun;
double planDiam;
};
string planName;
double planDistSun;
double planDiam;
};
Quote:
QUOTE
Create an array of 3 planet structures.
Does my book mean something like this? What type of array should I use? Could I use a char array?
Code:
CODE
Planet Mars;
Planet Earth;
Planet Jupiter;
char planetAry[3];
planetAry[0]=Mars;
planetAry[1]=Earth;
planetAry[2]=Jupiter;
Planet Earth;
Planet Jupiter;
char planetAry[3];
planetAry[0]=Mars;
planetAry[1]=Earth;
planetAry[2]=Jupiter;
Quote:
QUOTE
Include a function to enter the information for each planet. Use pointer notation to assign the values.
How would I do this? I understand that I can do something like:
Mars.planDiam=50000;
Mars.planDistSun=9000000
but how would I allow the user to enter a name for the planet then make a structure object though. I could just preassign the planets but thats not how he wants it.
Quote:
QUOTE
A function to show all the info for each planet. Use pointer arithmetic to move from one array position to the next.
I dont know how I would go about doing this? Any ideas would be helpful.
kvarnerexpress

