
Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes

Hi Friend,
Try the following code:
import java.util.*;
class WashingMachine
{
Scanner input=new Scanner(System.in);
public void switchOn () {
System.out.println ("The lid is open.");
}
public void acceptDetergent () {
System.out.println("Adding Detergent.. ");
}
public int acceptClothes(){
System.out.println("Enter no of clothes: ");
int no=input.nextInt();
return no;
}
public void switchOff () {
System.out.println ("The lid is closed.");
}
public static void main(String[] args)
{
WashingMachine wm=new WashingMachine();
wm.switchOn();
int numOFClothes=wm.acceptClothes();
wm.acceptDetergent();
wm.switchOff();
System.out.println(numOFClothes+" clothes get washed");
}
}
Thanks