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

An astronomy application displays information about the eight planets in our sol

ID: 3605889 • Letter: A

Question

An astronomy application displays information about the eight planets in our solar system. Write the logic for this application in pseudocode:

a. Visit this web page: https://sciencing.com/order-planets-distance-sun8371065.html

b. Note down each planet’s name, distance from the sun, and diameter

c. Write the program such that it:

i. Displays a numbered list of the planets that includes 1. Planet number (1 is the planet closest to the sun and 8 is the one farthest from it) 2. Planet’s name 3. Distance from the sun 4. Diameter Here is a sample of the required format of output: Planet #1: Mercury is 36 million miles from the sun and has a diameter of 3031 miles

ii. Allows the user to enter the number of any planet, and displays output similar to that shown above, for that planet, e.g., if the user entered 1, the output would be the sentence shown above. If the user enters an invalid planet number, such as zero or 9, the program must display an error message.

iii. Allows the user to enter the numbers of any two planets, and outputs both their names as well as their distance from each other. If the user enters an invalid planet number, such as zero or 9, the program must display an error message.

Note: (ii) and (iii) above must be accomplished without any search being performed

Explanation / Answer

Below is pseudocode to get details about planet.

//create class with variables for planet details

Class Planet {

order,

name,

distance,

diameter

}

//Create array of object of above class

Planet [] obj = new Planet[8];

//add planet details in array as
    obj[0].order = 1;
    obj[0].name = “marcury”;
    obj[0].distance = 36;
    obj[0].diameter = 3031;

    obj[1].order = 2;
    .
    .
    .

//Now to print planet information sequentially, iterate over array of object as
start from variable i=0 to i< size of obj, increment i
                (print obj[i].name + “is” + obj.distance + “ million miles from the sun and has a diameter of” + 3031 + “miles.”);

//To find information about particular planet
      get planet number say variable num.
   iterate over array
       start from variable i=0 to i< size of obj, increment i

              If obj[i] = num then
                     (print obj[i].name+ “is” + obj.distance + “ million miles from the sun and has a diameter of” + obj[i].diameter + “miles.”);
Else

      print error message

//To find distance between two planets

       get planet numbers say variable num_1, num_2.
      
         start from variable i=0 to i< size of obj, increment i

                        If obj[i] = num_1 then

start from variable j=0 to j< size of obj, increment j

if obj[j] = num_2 then

print“Planet”+ obj[i].name + “is distant from” + obj[j].name + “by” + (obj[i].distance – obj[j].distance);
Else

print error message

    Else

      print error message

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