SlideShare a Scribd company logo
1 of 3
Download to read offline
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

More Related Content

Similar to You have been hired by Planet Poachers to write a Java console appli.pdf

import java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docximport java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docxwilcockiris
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docxtheodorelove43763
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxmary772
 
In JavaWrite a program that reads a file and counts how many line.pdf
In JavaWrite a program that reads a file and counts how many line.pdfIn JavaWrite a program that reads a file and counts how many line.pdf
In JavaWrite a program that reads a file and counts how many line.pdfsuresh640714
 
Hands On Intro to Node.js
Hands On Intro to Node.jsHands On Intro to Node.js
Hands On Intro to Node.jsChris Cowan
 
Hadoop institutes in Bangalore
Hadoop institutes in BangaloreHadoop institutes in Bangalore
Hadoop institutes in Bangaloresrikanthhadoop
 
Question 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdfQuestion 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdfanjandavid
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfPRATIKSINHA7304
 
Write a java program that allows the user to input the name of a fil.docx
 Write a java program that allows the user to input  the name of a fil.docx Write a java program that allows the user to input  the name of a fil.docx
Write a java program that allows the user to input the name of a fil.docxajoy21
 
Write a java program that allows the user to input the name of a file.docx
Write a java program that allows the user to input  the name of a file.docxWrite a java program that allows the user to input  the name of a file.docx
Write a java program that allows the user to input the name of a file.docxnoreendchesterton753
 
Please I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfPlease I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfasenterprisestyagi
 

Similar to You have been hired by Planet Poachers to write a Java console appli.pdf (20)

import java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docximport java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
 
Java
JavaJava
Java
 
Java Enterprise Edition
Java Enterprise EditionJava Enterprise Edition
Java Enterprise Edition
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
 
In JavaWrite a program that reads a file and counts how many line.pdf
In JavaWrite a program that reads a file and counts how many line.pdfIn JavaWrite a program that reads a file and counts how many line.pdf
In JavaWrite a program that reads a file and counts how many line.pdf
 
Hands On Intro to Node.js
Hands On Intro to Node.jsHands On Intro to Node.js
Hands On Intro to Node.js
 
srgoc
srgocsrgoc
srgoc
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Hadoop institutes in Bangalore
Hadoop institutes in BangaloreHadoop institutes in Bangalore
Hadoop institutes in Bangalore
 
MaxTemp PPT.pptx
MaxTemp PPT.pptxMaxTemp PPT.pptx
MaxTemp PPT.pptx
 
Question 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdfQuestion 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdf
 
Book
BookBook
Book
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
 
Hadoop 2
Hadoop 2Hadoop 2
Hadoop 2
 
Hadoop 3
Hadoop 3Hadoop 3
Hadoop 3
 
Tech talk
Tech talkTech talk
Tech talk
 
Write a java program that allows the user to input the name of a fil.docx
 Write a java program that allows the user to input  the name of a fil.docx Write a java program that allows the user to input  the name of a fil.docx
Write a java program that allows the user to input the name of a fil.docx
 
Write a java program that allows the user to input the name of a file.docx
Write a java program that allows the user to input  the name of a file.docxWrite a java program that allows the user to input  the name of a file.docx
Write a java program that allows the user to input the name of a file.docx
 
Please I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfPlease I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdf
 

More from amitbagga0808

Describe the role of soil microbes in the formation and maintenance .pdf
Describe the role of soil microbes in the formation and maintenance .pdfDescribe the role of soil microbes in the formation and maintenance .pdf
Describe the role of soil microbes in the formation and maintenance .pdfamitbagga0808
 
Chapter 9Problem P 9-1The narrative and systems flowchart for.pdf
Chapter 9Problem P 9-1The narrative and systems flowchart for.pdfChapter 9Problem P 9-1The narrative and systems flowchart for.pdf
Chapter 9Problem P 9-1The narrative and systems flowchart for.pdfamitbagga0808
 
Compare and contrast the thick and thin filaments.SolutionTher.pdf
Compare and contrast the thick and thin filaments.SolutionTher.pdfCompare and contrast the thick and thin filaments.SolutionTher.pdf
Compare and contrast the thick and thin filaments.SolutionTher.pdfamitbagga0808
 
Anatomy can be studied in many ways. Regional anatomy is the study of.pdf
Anatomy can be studied in many ways. Regional anatomy is the study of.pdfAnatomy can be studied in many ways. Regional anatomy is the study of.pdf
Anatomy can be studied in many ways. Regional anatomy is the study of.pdfamitbagga0808
 
A red blood cell enters the right atrium from the superior vena cava..pdf
A red blood cell enters the right atrium from the superior vena cava..pdfA red blood cell enters the right atrium from the superior vena cava..pdf
A red blood cell enters the right atrium from the superior vena cava..pdfamitbagga0808
 
An organism that has a normal diploid autosome set with an XXY sex c.pdf
An organism that has a normal diploid autosome set with an XXY sex c.pdfAn organism that has a normal diploid autosome set with an XXY sex c.pdf
An organism that has a normal diploid autosome set with an XXY sex c.pdfamitbagga0808
 
Which level of Orange Book protection is considered mandatory protec.pdf
Which level of Orange Book protection is considered mandatory protec.pdfWhich level of Orange Book protection is considered mandatory protec.pdf
Which level of Orange Book protection is considered mandatory protec.pdfamitbagga0808
 
Why is it an advantage for the epiglottis to fit over the trachea.pdf
Why is it an advantage for the epiglottis to fit over the trachea.pdfWhy is it an advantage for the epiglottis to fit over the trachea.pdf
Why is it an advantage for the epiglottis to fit over the trachea.pdfamitbagga0808
 
This is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdfThis is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdfamitbagga0808
 
What factors are likely to be involved in setting the limit to how lo.pdf
What factors are likely to be involved in setting the limit to how lo.pdfWhat factors are likely to be involved in setting the limit to how lo.pdf
What factors are likely to be involved in setting the limit to how lo.pdfamitbagga0808
 
What is alternative splicing What is the difference between mRNA sp.pdf
What is alternative splicing What is the difference between mRNA sp.pdfWhat is alternative splicing What is the difference between mRNA sp.pdf
What is alternative splicing What is the difference between mRNA sp.pdfamitbagga0808
 
What are histones and their role in regulating transcription. .pdf
What are histones and their role in regulating transcription. .pdfWhat are histones and their role in regulating transcription. .pdf
What are histones and their role in regulating transcription. .pdfamitbagga0808
 
What are the cellular differences between fungi and protistsSol.pdf
What are the cellular differences between fungi and protistsSol.pdfWhat are the cellular differences between fungi and protistsSol.pdf
What are the cellular differences between fungi and protistsSol.pdfamitbagga0808
 
on the basis of the above data, list the media in order according to.pdf
on the basis of the above data, list the media in order according to.pdfon the basis of the above data, list the media in order according to.pdf
on the basis of the above data, list the media in order according to.pdfamitbagga0808
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfamitbagga0808
 
Prove that is L is regular and h is a homomorphism, then h(L) is.pdf
Prove that is L is regular and h is a homomorphism, then h(L) is.pdfProve that is L is regular and h is a homomorphism, then h(L) is.pdf
Prove that is L is regular and h is a homomorphism, then h(L) is.pdfamitbagga0808
 
Not sure how to do this case analysis please help me do it!1.Are t.pdf
Not sure how to do this case analysis please help me do it!1.Are t.pdfNot sure how to do this case analysis please help me do it!1.Are t.pdf
Not sure how to do this case analysis please help me do it!1.Are t.pdfamitbagga0808
 
In each of the following situations, data are obtained by conducting .pdf
In each of the following situations, data are obtained by conducting .pdfIn each of the following situations, data are obtained by conducting .pdf
In each of the following situations, data are obtained by conducting .pdfamitbagga0808
 
i need a summary book report on thw Iwoby richard wheelerSolut.pdf
i need a summary book report on thw Iwoby richard wheelerSolut.pdfi need a summary book report on thw Iwoby richard wheelerSolut.pdf
i need a summary book report on thw Iwoby richard wheelerSolut.pdfamitbagga0808
 
18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdf
18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdf18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdf
18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdfamitbagga0808
 

More from amitbagga0808 (20)

Describe the role of soil microbes in the formation and maintenance .pdf
Describe the role of soil microbes in the formation and maintenance .pdfDescribe the role of soil microbes in the formation and maintenance .pdf
Describe the role of soil microbes in the formation and maintenance .pdf
 
Chapter 9Problem P 9-1The narrative and systems flowchart for.pdf
Chapter 9Problem P 9-1The narrative and systems flowchart for.pdfChapter 9Problem P 9-1The narrative and systems flowchart for.pdf
Chapter 9Problem P 9-1The narrative and systems flowchart for.pdf
 
Compare and contrast the thick and thin filaments.SolutionTher.pdf
Compare and contrast the thick and thin filaments.SolutionTher.pdfCompare and contrast the thick and thin filaments.SolutionTher.pdf
Compare and contrast the thick and thin filaments.SolutionTher.pdf
 
Anatomy can be studied in many ways. Regional anatomy is the study of.pdf
Anatomy can be studied in many ways. Regional anatomy is the study of.pdfAnatomy can be studied in many ways. Regional anatomy is the study of.pdf
Anatomy can be studied in many ways. Regional anatomy is the study of.pdf
 
A red blood cell enters the right atrium from the superior vena cava..pdf
A red blood cell enters the right atrium from the superior vena cava..pdfA red blood cell enters the right atrium from the superior vena cava..pdf
A red blood cell enters the right atrium from the superior vena cava..pdf
 
An organism that has a normal diploid autosome set with an XXY sex c.pdf
An organism that has a normal diploid autosome set with an XXY sex c.pdfAn organism that has a normal diploid autosome set with an XXY sex c.pdf
An organism that has a normal diploid autosome set with an XXY sex c.pdf
 
Which level of Orange Book protection is considered mandatory protec.pdf
Which level of Orange Book protection is considered mandatory protec.pdfWhich level of Orange Book protection is considered mandatory protec.pdf
Which level of Orange Book protection is considered mandatory protec.pdf
 
Why is it an advantage for the epiglottis to fit over the trachea.pdf
Why is it an advantage for the epiglottis to fit over the trachea.pdfWhy is it an advantage for the epiglottis to fit over the trachea.pdf
Why is it an advantage for the epiglottis to fit over the trachea.pdf
 
This is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdfThis is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdf
 
What factors are likely to be involved in setting the limit to how lo.pdf
What factors are likely to be involved in setting the limit to how lo.pdfWhat factors are likely to be involved in setting the limit to how lo.pdf
What factors are likely to be involved in setting the limit to how lo.pdf
 
What is alternative splicing What is the difference between mRNA sp.pdf
What is alternative splicing What is the difference between mRNA sp.pdfWhat is alternative splicing What is the difference between mRNA sp.pdf
What is alternative splicing What is the difference between mRNA sp.pdf
 
What are histones and their role in regulating transcription. .pdf
What are histones and their role in regulating transcription. .pdfWhat are histones and their role in regulating transcription. .pdf
What are histones and their role in regulating transcription. .pdf
 
What are the cellular differences between fungi and protistsSol.pdf
What are the cellular differences between fungi and protistsSol.pdfWhat are the cellular differences between fungi and protistsSol.pdf
What are the cellular differences between fungi and protistsSol.pdf
 
on the basis of the above data, list the media in order according to.pdf
on the basis of the above data, list the media in order according to.pdfon the basis of the above data, list the media in order according to.pdf
on the basis of the above data, list the media in order according to.pdf
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
 
Prove that is L is regular and h is a homomorphism, then h(L) is.pdf
Prove that is L is regular and h is a homomorphism, then h(L) is.pdfProve that is L is regular and h is a homomorphism, then h(L) is.pdf
Prove that is L is regular and h is a homomorphism, then h(L) is.pdf
 
Not sure how to do this case analysis please help me do it!1.Are t.pdf
Not sure how to do this case analysis please help me do it!1.Are t.pdfNot sure how to do this case analysis please help me do it!1.Are t.pdf
Not sure how to do this case analysis please help me do it!1.Are t.pdf
 
In each of the following situations, data are obtained by conducting .pdf
In each of the following situations, data are obtained by conducting .pdfIn each of the following situations, data are obtained by conducting .pdf
In each of the following situations, data are obtained by conducting .pdf
 
i need a summary book report on thw Iwoby richard wheelerSolut.pdf
i need a summary book report on thw Iwoby richard wheelerSolut.pdfi need a summary book report on thw Iwoby richard wheelerSolut.pdf
i need a summary book report on thw Iwoby richard wheelerSolut.pdf
 
18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdf
18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdf18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdf
18 Alicia climbs into the passenger side of her boyfriend Bos car. .pdf
 

Recently uploaded

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Recently uploaded (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

You have been hired by Planet Poachers to write a Java console appli.pdf

  • 1. 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
  • 2. 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()) {
  • 3. 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