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

Follows all the instructions given below: Keep the program\'s code as simple as

ID: 3793894 • Letter: F

Question

Follows all the instructions given below:

Keep the program's code as simple as possible, only one class is used - begineer level (with no advance techniques like enum, try catch block, etc...)

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 3Opal Steven Amethyst- Smoky Quartz Connie Steven Stevonnie 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 Note: The user should be able to enter the names in any order to get the result. So the user should be able to enter Pearl, then Garnet and get the same result as Garnet, then Pearl. You will need 1. A scanner object for input 2. Variables to store the two gems 3. 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 equalslgnoreCase method to ensure that the code recognizes the gem's name regardless of the case entered. 4. 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

import java.util.Scanner;
public class HelloWorld{

public static void main(String []args){
Scanner sc=new Scanner(System.in);
System.out.println("who is first gem ?");
String nam1=sc.next(); //To take input from user
String name1=nam1.toLowerCase(); // TO covert string to lowercase
System.out.println("who is second gem ?");
String nam2=sc.next();
String name2=nam2.toLowerCase();
System.out.println(name1 +" " +name2); // Print both string in lowercase on consloe

//Different condition for checking of both input given in any order
if((name1=="garnet" && name2=="pearl")|| (name1=="peral" && name2=="garnet"))
System.out.println("when"+ name1+ "and " +name2+"fuse they create sardonyx");
else if((name1=="garnet" && name2=="amethyst")|| (name1=="amethyst" && name2=="garnet"))
System.out.println("when"+ name1+ "and " +name2+"fuse they create sugilite");
else if((name1=="pearl" && name2=="amethyst")|| (name1=="amethyst" && name2=="pearl"))
System.out.println("when"+ name1+ "and " +name2+"fuse they create opal");
else if((name1=="steven" && name2=="amethyst")|| (name1=="amethyst" && name2=="steven"))
System.out.println("when"+ name1+ "and " +name2+"fuse they create smoky quartz");
else if((name1=="steven" && name2=="connie")|| (name1=="connie" && name2=="steven"))
System.out.println("when"+ name1+ "and " +name2+"fuse they create stevonnie");
  
  
}
}