Question: Java Help Modify the Interface sample program by adding another Interface class that would produce the following output (new output in red): Shutdown HiVac chamber?

Java Help

Modify the Interface sample program by adding another Interface class that would produce the following output (new output in red):

Shutdown HiVac chamber? Y or N ->: y Heater shutting down... Heater power off... Heater at ambient temperature. Gate valves closing... All gate valves closed. HiVac turbo spinning down... HiVac turbo spun down Currently @ 0.0 rpm. Pressure release valve on HiVac chamber opening... Pressure @ 1 atmosphere (760 torr) Safe to open chamber. The production line has been suspended.

Pumping down chamber... Chamber pumped down and @ 0 torr. HiVac turbo spinning up... HiVac turbo @ speed. Gate valves opening... All gate valves open. Heater power on... Heater starting... Heater at operating temperature. System ready for production.

Please upload ONLY the new code/edited sections and new class in a PDF or text file form.

************************************** My answer

interface hivac

{

//call the shutdown function

void shutdown();

}

class sample implements hivac

{

String in;

public void shutdown()

{

//get the input from user

System.out.println("Shutdown HiVac chamber? Y or N ->:");

Scanner sc = new Scanner(System.in);

in=sc.next();

System.out.println(in);

//if the input is Y or y, then print the below statement

if(in=="Y"||in=="y")

{

System.out.println("Heater shutting down...");

System.out.println("Heater power off...");

System.out.println("Heater at ambient temperature.");

System.out.println("Gate valves closing...");

System.out.println("All gate valves closed.");

System.out.println("HiVac turbo spinning down...");

System.out.println("HiVac turbo spun down");

System.out.println("Currently @ 0.0 rpm.");

System.out.println("Pressure release valve on HiVac chamber opening...");

System.out.println("Pressure @ 1 atmosphere (760 torr)");

System.out.println("Safe to open chamber.");

System.out.println("The production line has been suspended.");

}

}

}

public class ShutdownInterface implements hivac

{

//main method

public static void main(String args[])

{

//create the object for sample class

sample s=new sample();

//create the object for ShutdownInterface class

ShutdownInterface sd=new ShutdownInterface();

System.out.println("First method called");

//call the shutdown() for sample class

s.shutdown();

System.out.println("Second method called");

//call the shutdown() for ShutdownInterface class

sd.shutdown();

}

public void shutdown()

{

System.out.println("Pumping down chamber...");

System.out.println("Chamber pumped down and @ 0 torr.");

System.out.println("HiVac turbo spinning up...");

System.out.println("HiVac turbo @ speed.");

System.out.println("Gate valves opening...");

System.out.println("All gate valves open.");

System.out.println("Heater power on...");

System.out.println("Heater starting...");

System.out.println("Heater at operating temperature.");

System.out.println("System ready for production.");

}

}

************************************ My teachers comments

Please help me fix this.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!