[SOLVED] SOLVED: Lab 3 - Decisions - Planets

19.99 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Planets.zip (1.4 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (3 votes)

Lab 3 – Decisions

Here is a table that describes the planets in our solar system numbered according to their distance from the sun:

1. Mercury
2. Venus
3. Earth
4. Mars
5. Jupiter
6. Saturn
7. Uranus
8. Neptune

Use the code below to input an integer from the user. Write a switch statement that examines the integer and prints out the name of the corresponding planet. Print an error message if an invalid integer is entered.

“`java
import java.util.Scanner;

public class Planets

{

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

System.out.print(“Enter a planet number from the sun: “);

int planet = scan.nextInt();

// Your code goes here …

}

}
“`

  • Planets.zip