#include #include #include #include #define max 1000 #define

#include
#include
#include
#include
#define max 1000
#define min 1
#define num_asteroids 10
#define max_distance 750
#define pos_dimensions 3
struct User
{
char name[20];
int pin;
};
int numberOfUsers(char* filename);
void readIdent(struct User *users,char* filename);
int verifyUser(struct User *users, int no_of_users);
void readAsteroidsData(char* asteroids,int attributes, int positions[][3]);
void writeAsteroidsTxt(int no_of_asteroids);
int getRandomNumber();
double calculateDistance(int x, int y, int z);
double calculateTime(double distance);
void writeToDistanceFile(char* asteroids,int no_of_asteroids, int attributes, int positions[][attributes]);
void readDistanceData(char* asteroids, int attributes, int distances[][attributes]);
void displayBarChart(char* asteroids,int no_of_asteroids, int attributes,int distances[][attributes]);
void sortArray(char* asteroids,int no_of_asteroids, int attributes,int distances[][attributes]);
void printArray(char* asteroids,int no_of_asteroids, int attributes,int distances[][attributes]);
int main()
{
//Common Variables
int no_of_users = numberOfUsers(“ident.txt”);
//int position_dimensions=3;
//Declare Arrays
char asteroids[num_asteroids];
struct User users[no_of_users];
int positions[num_asteroids][pos_dimensions];
time_t t;
srand ( (unsigned) time (&t));
//Verify User
readIdent(users,”ident.txt”);
if(verifyUser(users,no_of_users)==1)
{
printf(“nSuccessfully verifiednn”);
writeAsteroidsTxt(num_asteroids);
printf(“Asteriods positions written to filen”);
readAsteroidsData(asteroids,pos_dimensions,positions);
printf(“Asteriods positions read from filenn”);
//We now have the asteroids in a multidimensional array
//Calculate Distance and send
writeToDistanceFile(asteroids,num_asteroids,pos_dimensions,positions);
printf(“nAsteriods Distance from Spaceship written to filen”);
char aste[num_asteroids];
int distances[num_asteroids][pos_dimensions+1];
readDistanceData(aste,(pos_dimensions+1),distances);
printf(“Asteriods Distance from Spaceship read from filenn”);
printf(“Display Bar Chart of Distancesn”);
displayBarChart(aste,num_asteroids,pos_dimensions+1,distances);
sortArray(aste,num_asteroids,pos_dimensions+1,distances);
printf(“Asteroid Ranking from the closest to the furthest is as follows: n”);
printArray(aste,num_asteroids,pos_dimensions+1,distances);
printf(“Displaying Bar Chart After Sortingn”);
displayBarChart(aste,num_asteroids,pos_dimensions+1,distances);
}
else
{
printf(“Access Deniedn”);
}
return 0;
}
void printArray(char* asteroids,int no_of_asteroids, int attributes,int distances[][attributes])
{
for(int i=0;i