You have been hired by Planet Poachers to write a Java conso

You have been hired by Planet Poachers to write a Java console application that reads, converts, sorts, and writes planet data. Create text file PlanetDataEnglish.txt, paste the following data into it, and place the file in your project folder.

PlanetDataEnglish.txt
Planet Escape Velocity (miles/s) Mean Temperature (F) Number of Moons
Mercury 2.7 333 0
Venus 6.4 867 0
Earth 7.0 59 1
Mars 3.1 -85 2
Jupiter 37.0 -166 67
Saturn 22.1 -220 62
Uranus 13.2 -320 27
Neptune 14.6 -330 13
Pluto 0.7 -375 5

Create the following methods:

Column Purpose
readTextFile To read the data from file PlanetDataEnglish.txt into four parallel arrays: planets, escapes, means, and moons.
printArrays To print the unsorted, converted, and sorted data using the appropriate column headers.
convertArrays To convert the escape velocities from miles/s to km/s, and to convert the mean temperatures from Fahrenheit to Celsius.
bubbleSortArray To sort the data by planet name in ascending order. Note that when values are swapped in one array, the same values must be swapped in the other arrays.
writeTextFile To write the data to file PlanetDataMetric.txt in the same layout as the input file.

Sample Output on .txt file

PlanetDataMetric.txt
Planet Escape Velocity (miles/s) Mean Temperature (F) Number of Moons
Earth 11.3 15 1
Jupiter 59.5 -110 67 …

Solution

Following will be program for the planet as requested

//Inclusion of the lib files

Import Java.util.scanner;

import java.io.Filewriter;

import java.io.PrintWriter;

Import java.io.FileNotFoundException;

import java.util.InputMismatchException;

import java.io.IOException;

import java.io.File;

Public class Planets // Main method is followed

{

public static void main(String[] args) // main mehtod

{

// variables are declared

scanner keyboard = new Scanner(System.in); // here the keyboard will be connected

Scanner fileIn = null; //file variable are declared

String fileInName = \"PlanetSourceData.txt\";// File name variable is declared

int i=0;

int j=0;

int k =0;

int Usednumber = 10;

String [] Plantets = new String[20];

int [] diameters = new int[15];

double [] leng = newdouble [12];

try

{

fileIn = new Scanner(new FileInputStream(fileInName)); //Scanning of the text file is done

}

Catch(FileNotFoundException e) \\\\catching of the exception

{

System.out.printIn(\"Error:File \'\" +fileInName+ \"\' not found.\"); //gives the error message that file is not found

System.exit(-1);

}

System.out.println(\"This is templelate from Java keyboard entry\");

// To read the input file this loop is formed

while(fieIn.hasNextLine())

{

Planets[i] = fileIn.next();

diameters[j] = fileIn.nextInt();

lengths[k] = fileIn.nextDouble();

System.out.Printf(\"%-10 %8s %8s %n\" , \"Planets\", \"Diameter(miles)\",\" Hours of the planest(Length of the planet:);

System.out.printf(\"%-10s %8d %8.1f 5n \", planets[i], diameters[j] , lenths [k]);

}

PrintArray(diameters, numberUsed);

bubbleSortArray(diameters,numberUsed); //finding the miles(escape velocity)

printArray(duameters,numberUsed);

}

Public static voidbubbleSortArray(int[]a, intnumberUsed)

{

int i,j;

int temp; //declaration of the variables

for (i=0 ; i<usednumber; i++)

{

for ( j=usednumber -1; j<i;j--) // nested for loop

{

if(a[j]<a[j-1])

{

temp = a[j];

a[j] = a[j-1];

a[j-i] = temp; // swapping of the values using the temp varables

printArray(a, usednumber);

}

}

}

}

Public static void printArray(int[] a, int usednumber){ // to print the values

int i ; //varialbe declaration

for (i=0;i<usednumber ; i++)

{

System.out.printf(\"%3d\",a[i]);

}

System.out.println();

}

}

You have been hired by Planet Poachers to write a Java console application that reads, converts, sorts, and writes planet data. Create text file PlanetDataEngli
You have been hired by Planet Poachers to write a Java console application that reads, converts, sorts, and writes planet data. Create text file PlanetDataEngli
You have been hired by Planet Poachers to write a Java console application that reads, converts, sorts, and writes planet data. Create text file PlanetDataEngli

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site