Hi I have 2 class now that need to store x and y to one array and some other attributes to another array so that i could do some computing and display both arrays as a top 5 list.
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <fstream>
#include "PointTwoD.h"
usingnamespace std;
class MissionPlan
{
};
string sunType;
LocationData ld;
int i;
int x;
int y;
int noOfEarthLikePlanets;
int noOfEarthLikeMoons;
float aveParticulateDensity;
float avePlasmaDensity;
float distance;
void mainMenu();
void showEntry();
void showDistance();
float computeCivIndex();
void showTopFive();
//PointTwoD& PointTwoD::operator=(const PointTwoD &aPointTwoD)
//{
// x = aPointTwoD.x;
// y = aPointTwoD.y;
// xArray = new int[x];
//for (i = 0; i < aPointTwoD.x; ++i)
//{
// xArray[i] = aPointTwoD.xArray[i];
//}
// return *this;
//}
void mainMenu()
{
cout<<"Welcome to Mission Plan program!"<<endl<<endl<<
"1)Input statistical data."<<endl<<
"2)Compute civ. index value (for all records)"<<endl<<
"3)Print top 5 exploration destinations."<<endl<<
"4)Print total travel distance."<<endl<<endl;
}
//{
// distance = sqrt(((x*x) + (y*y))*100);
//Output
// cout << "Total (approx) travel distance = ";
// cout << distance <<" million km"<< endl;
//}
//*********
//void showTopFive()
//{
// cout<<endl<<"Total no. of records available = "<<endl;
// cout<<endl<<"Printing top 5 deploration destinations ..."<<endl;
// cout<<endl<<"1) "<<endl;
// cout<<endl<<"2) "<<endl;
// cout<<endl<<"3) "<<endl;
// cout<<endl<<"4) "<<endl;
// cout<<endl<<"5) "<<endl<<endl<<endl;
// cout<<endl<<"Done!"<<endl;
//}
//****************
void showEntry()
{
int xArray[10];
for (i = 0; i < 1; i++)
cout<<"Input statistical data"<<endl<<endl;
cout<<"Please enter x-cordinate:";
cin>>xArray[i];
// dataStore.getX(x);
int yArray[10];
for (i = 0; i < 1; i++)
cout<<"Please enter y-cordinate:";
cin>>yArray[i];
// y = new int[num];
int dataStore[100];
int getData;
int counter;
cout<<"Please enter sun type: ";
cin>>sunType;
//ld.setSunType(sunT);
cout<<"Please enter no. of earth-like planets:";
cin>>noOfEarthLikePlanets;
//ld.setNoOfEarthLikePlanets(noOfEarthLikePlanets);
cout<<"Please enter no. of earth-like moons:";
cin>>noOfEarthLikeMoons;
//ld.setNoOfEarthLikeMoon(noOfEarthLikeMoons);
cout<<"Please enter ave. particulate density (%-tage):";
cin>>aveParticulateDensity;
//ld.setAveParticulateDensity(aveParticulateDensity);
cout<<"Please enter ave. plasma density (%-tage):";
cin>>avePlasmaDensity;
//ld.setAvePlasmaDensity(avePlasmaDensity);
dataStore[i]=ld.toString();
i++;
cout<<"Record succesfully stored. Going back to main menu."<<endl;
}
int choice;
int main()
{
constint x = 100;
int list[x];
mainMenu();
cout<<"Please select your choice : ";
cin>>choice;
switch(choice)
{
case 1 :
showEntry();
mainMenu();
cout<<"Please select your choice : ";
cin>>choice;
return 0;
break;
case 2 :
for (int i = 0; i <1; i++)
cout<<endl<<x<<endl;
// computeCivIndex();
cout<<endl<<"Computation Completed! (""records were updated )"<<endl;
break;
case 3 :
// showTopFive();
//void showTopFive(list<PointTwoD> &clist)
//{
// list <PointTwoD>::iterator i;
// sort(clist.begin(), clist.end());
//
// do
//{
// for (i = clist.begin(); i != clist.end(); i++)
//{
//cout << "Civ Idx : " << ld.computeCivIndex(i->ld.getSunType(), i->ld.getNoOfEarthLikePlanets(), i->ld.getNoOfEarthLikeMoons(), i->ld.getAveParticulateDensity(), i->ld.getAvePlasmaDensity()) << " at sector(" << i->getX() << "," << i->getY() << ")" << endl;
//}
//}
//while(i==5);
//}
cout<<"Please select your choice : ";
cin>>choice;
return 0;
break;
case 4 :
//showDistance();
cout<<"Please select your choice : ";
cin>>choice;
return 0;
break;
default: cout<<"Invalid choice, please re-enter your choice."<<endl;
}
return 0;
}
I have no error in this and have use the for (i = 0; i < 1; i++) method,
but it doesnt seems to be working...how to make it display the first list of 5 input?