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

Write a program that simulates the gem fusions that occur in the TV show \"Steve

ID: 3820432 • Letter: W

Question

Write a program that simulates the gem fusions that occur in the TV show "Steven Universe." According to the show, the following fusions occurred between the good gems and/or humans: Garnet + Pearl = Sardonyx Garnet + Amethyst = Sugilite Pearl + Amethyst = Opal Steven + Amethyst = Smoky Quartz Connie + Steven = With this information, write a program that asks the users for the names of two gems/humans and outputs the fusion that they create. If the user enters a combination other than the ones entered, report that there is "No known fusion." A scanner object for input Variables to store the two gems A nested if-else statement to output the appropriate fusion 1. Use logical operators to ensure that the correct fusion is obtained for any order 2. Use the Case method to ensure that the code recognizes the gem's name regardless of the case entered. Comments for appropriate documentation A sample of the output is shown below: Who is the first gem? Amethyst Who is the second gem? Pearl When Amethyst and Pearl fuse, they create Opal.

Explanation / Answer

GemFusions.java

import java.util.Scanner;

public class GemFusions {

   public static void main(String[] args) {
       //Declaring variables
   String firstgem,secondgem;
      
       //Scanner object is used to get the inputs entered by the user
       Scanner sc=new Scanner(System.in);
      
       //Getting the inputs entered by the user
       System.out.print("Who is the first gem?");
       firstgem=sc.next();
      
       System.out.print("Who is the second gem?");
       secondgem=sc.next();
      
      
       //Based on the user input gem names display
       if((firstgem.equalsIgnoreCase("Garnet") && secondgem.equalsIgnoreCase("Pearl")) || (firstgem.equalsIgnoreCase("Pearl") && secondgem.equalsIgnoreCase("Garnet")))
       {
           System.out.println(" When "+firstgem+" and "+secondgem+" fuse, they create Sardonyx.");
       }
       else if((firstgem.equalsIgnoreCase("Garnet") && secondgem.equalsIgnoreCase("Amethyst")) || (firstgem.equalsIgnoreCase("Amethyst") && secondgem.equals("Garnet")))
       {
           System.out.println(" When "+firstgem+" and "+secondgem+" fuse, they create Sugilite.");
       }
       else if((firstgem.equalsIgnoreCase("Pearl") && secondgem.equalsIgnoreCase("Amethyst")) || (firstgem.equalsIgnoreCase("Amethyst") && secondgem.equalsIgnoreCase("Pearl")))
       {
           System.out.println(" When "+firstgem+" and "+secondgem+" fuse, they create Opal.");
       }
       else if((firstgem.equalsIgnoreCase("Steven") && secondgem.equalsIgnoreCase("Amethyst")) || (firstgem.equalsIgnoreCase("Amethyst") && secondgem.equalsIgnoreCase("Steven")))
       {
           System.out.println(" When "+firstgem+" and "+secondgem+" fuse, they create Smoky Quartz.");
       }
       else if((firstgem.equalsIgnoreCase("Connie") && secondgem.equalsIgnoreCase("Steven")) || (firstgem.equalsIgnoreCase("Steven") && secondgem.equalsIgnoreCase("Connie")))
       {
           System.out.println(" When "+firstgem+" and "+secondgem+" fuse, they create Stevonnie.");
       }
   }

}

________________

Output:

Who is the first gem?Amethyst
Who is the second gem?Pearl

When Amethyst and Pearl fuse, they create Opal.

____________Thank You

Please rate me well.If you are satisfied.

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