Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a main program to do the following,using class member functions 1) Open a

ID: 3631941 • Letter: W

Question

Write a main program to do the following,using class member functions


1) Open a file called route.txt and connect it to the stream fin using

ifstream fin(“route.txt”);

The first line in the file contains the number of planets. Subsequent lines contain the id x y z coordinates of the planets.

2) Define an array called the_planets of 10 planet pointers, i.e. use the line

planet* the_planets[10]; // Are you sure why the syntax is like this?
We will assume for the present that there are never more than 10 deliveries per route

3) Each element of the array is to point to a particular planet, the details of which come from the file. Therefore use your generate_planet function within a loop to achieve this, maybe using the line.

the_planets [i]=generate_planet(fin);

4) Report the details of all the planets to the screen by using your report_planet function within a loop. Be careful that the_planets[i] is a pointer to a planet.

5) to scan through all possible routes and find the shortest one

Some comments;
To find the shortest route we will just do an exhaustive search – just considering
all possible routes in turn. So with 3 planets we could do
Our Base – the_planets[0] – the_planets[1] – the_planets[2] – our base
or
Our Base – the_planets[0] – the_planets[2] – the_planets[1] – our base
or
Our Base – the_planets[2] – the_planets[0] – the_planets[1] – our base
etc

We’ll limit ourselves to small numbers of locations to keep the calculation
practical (use the first 6 locations in route.txt) but please don’t assume a fixed
number.

We need to generate all possible routes. If we have n delivery locations then we
will specify a route by an integer array defined as
int *route=new int[n];
Each possible route will characterised as follows
route[0] – first delivery location
route[1] – second delivery location etc
Therefore the planets would be visited in the order
the_planets [route[0]] - the_planets [route[1]] - the_planets [route[2]] - etc

You will need the function

unsigned long int factorial(int n){

unsigned long int v(1);

for(int i=2;i<=n;i++) v*=i;

return(v);}

 

There is an example on thw website

Thank you very much !

Explanation / Answer

Hey friend...i know the answer. I have solved it in my notebook , but could not upload it . I don't know what is happening with upload... Give me lifesaver and write you email id .I'll send it to your email id .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote