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

Galileo was an unmanned NASA spacecraft which studied the planet Jupiter and its

ID: 3549123 • Letter: G

Question

Galileo was an unmanned NASA spacecraft which studied the planet Jupiter and its moons, as well as several other solar system bodies. It was launched on October 18, 1989, and arrived at Jupiter on December 7, 1995, becoming the first spacecraft to orbit Jupiter. . For this programming assignment , you will determine the number of burns required for the Galileo to reach any destination, most importantly Jupiter. Each burn sequence allows the spacecraft to travel 60% of the remaining distance to the final destination.  

For example, if the initial distance is 5000 meters, the spacecraft would travel (5000*0.6), or 3000 meters, on the first burn with 2000 meters left to travel. On the second burn, the spacecraft would travel (3000*0.6), or 1800 meters, with 200 meters left to travel. Write a Java application that prompts for the distance to be traveled in kilometers (you will need to convert this to meters). Then, determine the number of burns required to reach the destination within 35 meters. Output the burn number, how far the probe traveled for the burn, and the remaining distance to reach its destination. You must use a While loop in your script.

Now determine the actual number of burns required for your spacecraft to travel from Earth to Jupiter. Include the answer as a comment in your code. Note that the average distance from Earth to Jupiter is 778412028 million km.

Things to Note:

1. The Burn and distance traveled and the

Galileo was an unmanned NASA spacecraft which studied the planet Jupiter and its moons, as well as several other solar system bodies. It was launched on October 18, 1989, and arrived at Jupiter on December 7, 1995, becoming the first spacecraft to orbit Jupiter.. For this programming assignment , you will determine the number of burns required for the Galileo to reach any destination, most importantly Jupiter. Each burn sequence allows the spacecraft to travel 60% of the remaining distance to the final destination. For example, if the initial distance is 5000 meters, the spacecraft would travel (5000*0.6), or 3000 meters, on the first burn with 2000 meters left to travel. On the second burn, the spacecraft would travel (3000*0.6), or 1800 meters, with 200 meters left to travel. Write a Java application that prompts for the distance to be traveled in kilometers (you will need to convert this to meters). Then, determine the number of burns required to reach the destination within 35 meters. Output the burn number, how far the probe traveled for the burn, and the remaining distance to reach its destination. You must use a While loop in your script. Now determine the actual number of burns required for your spacecraft to travel from Earth to Jupiter. Include the answer as a comment in your code. Note that the average distance from Earth to Jupiter is 778412028 million km.

Explanation / Answer

import java.text.DecimalFormat;

import java.util.Scanner;


public class NumberOfBurns {


public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);

System.out.println("Enter the distance to be traveled in kilometers:");

int kilometers = scanner.nextInt();

int meters = kilometers*1000;

int i = 0;

String number = "";

String remaining = "";

//making a while loop which ll run until meter value remaining is does not reach 35 or lesser.

while (meters >= 35){

i++;


if (meters* 0.6 == (int)(meters* 0.6)){

DecimalFormat decimalInteger = new DecimalFormat("#");

number = decimalInteger.format(meters* 0.6);

}

else {

DecimalFormat decimal = new DecimalFormat("0.###");

number = decimal.format(meters* 0.6);

}

if (meters* 0.4 == (int)(meters* 0.4)){

DecimalFormat decimalInteger = new DecimalFormat("#");

remaining = decimalInteger.format(meters* 0.4);

}

else {

DecimalFormat decimal = new DecimalFormat("0.###");

remaining = decimal.format(meters* 0.4);

}


System.out.println("Burn "+i+": Traveled "+number);

System.out.println(" "+remaining +" meters to go");


meters = (int) (meters *0.4);

}

System.out.println("You made it to Jupiter in "+i+" burns");

}

}