arvind
java code 1 of 2
1 Answer(s)      2 years and 6 months ago
Posted in : JavaScript Questions

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

View Answers

December 21, 2010 at 5:58 PM


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









Related Pages:
java code 1 of 2
java code 1 of 2  Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes   Hi Friend, Visit
java code 1 of 2
java code 1 of 2  Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts... the following code: import java.util.*; class WashingMachine { Scanner input
java code 8 of 1
java code 8 of 1  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time
JSP Architecture, JSP Model 1 architecture, JSP Model 2 architecture
. In the JSP page programmers embeds Java code for generating dynamic content. JSP... of the architecture is used. These architectures are known as Model 1 and Model 2... Architecture Model 2 Architecture JSP Model 1 Architecture In case
WAP in java to print the series 1*2*3
WAP in java to print the series 1*2*3  WAP in java to print the series 123
array 1 - Java Beginners
array 1  WAP to input values in 2 arrays and merge them to array M.  Hi Friend, Try the following code: import java.util.*; class MergeArray{ public static int[] merge(int [] ... arr) { int arrSize = 0
Java programming 1 - Java Beginners
Java programming 1  write one program, which consists of a main... be at position 1, etc ?A sentence is constructed with a series of words? Index 0 1 2 3 4...? There are nine words in total Java has a standard to index elements starting
Java programming 1 - Java Beginners
Java programming 1  write one program, which consists of a main... 1 2 3 4 5 6 7 8 We need to provide a method...? There are nine words in total Java has a standard to index elements starting
Java programming 1 - Java Beginners
Java programming 1  thx sir for reply me..but sir can u pls simplify...; Hi friend, 1. Ask the user for their height. Convert it to a double. 2. Ask the user for their weight. Convert it to a double. 3. Use
contructors 1&test
the 'XXX' with the value of length using the Java keyword this in your code. â??h... of length, width and height using the Java keyword this in your code. When you... created with length 10 and width 15. Box created with length 1, width 2
Logging Tutorial - Part 1
Logging Tutorial - Part 1 2000-12-14 The Java Specialists' Newsletter [Issue 003] - Logging part 1 Author: Dr. Heinz M. Kabutz If you are reading... to the third "The Java(tm) Specialists' Newsletter", a low-volume newsletter
Java Programming: Chapter 1 Quiz
Quiz Questions For Chapter 1 THIS PAGE CONTAINS A SAMPLE quiz on material from Chapter 1 of this on-line Java textbook. You should be able...: If you have the source code for a Java program, and you want to run that program
Java Struts 2 Programmer
Java Struts 2 Programmer       Position Vacant: Java Struts 2 Programmer  Job... ID: Java Struts 2 Programmer
Code
Code  how to print this?? with the use of only JSP....... 1 23 456 78910   Here is the jsp number pattern example: 1 2 3 4 5 6 7 8 9 10 <%@page language="java"%> <% int k = 1; for(int i=1; i<= 4 ;i
More than 1 preparedStatement object - Java Beginners
Statement object in the java class.Try the following code: import java.sql.... =?"); pst1.setString(1, "Delhi"); pst1.setString(2... =?"); pst2.setString(1, "Agra"); pst2.setString(2, "AAAAA
JAVA leftshift operator add 1 instead of 0
JAVA leftshift operator add 1 instead of 0  Hi Guys, I have a task... this in java. Please help me asap. Thanks. Code Eater... to clipboardprint? byte a = 5, b; int i; i = a << 2; So, it will work like
Compare 2 files
Compare 2 files  I would like to compare 2 files in Java. please send me the code snipt for this scenario: File1... file 1 and 2. The file name will normally be the last 16 characters of a line
task 1 - Java Beginners
task 1  Please write a Java client that send a small letters string to a Java server which convert it to uppercase letters and send it back..., Try the following code: import java.util.*; class ChangeCase{ public
problem 1 - Java Beginners
problem 1   Hi, please help me!!!! How can i code in java using Two-dimensional Arrays? This question is related to the one i posted before. this is my input data file: 88 90 94 102 111 122 134 75 77 80 86 94 103 113 80
que 1 - Java Beginners
que 1  WAP to enter a sentence & count the no. of times a particular word occurs in it.Display the frequency of the searched word. eg- input...:frequency of word-2 times   Hi Friend, Try the following code: import
arrays part 2 - Java Beginners
arrays part 2  Question 2: Useful Array Algorithms and Operations (5 marks) Upgrade the program in Question 1 so that the program includes... index if the integer appears in the array o Returns -1 otherwise. ? A static
readline Error 2 - Java Beginners
readline Error 2  Hi sir, can you look again please. The error is hard to notice, but if you execute the code, 1. enter a string the first input request (eg hello world), 2. ENTER 3a. ENTER n for the next input request
Cohabitation struts 1 and 2 - Struts
Cohabitation struts 1 and 2  Hi, I have a problem with the cohabitation of struts 1 and 2. I work on a web application which used struts 1. But i must add some functionality in struts 2. When i modify my web.xml file
JOptionPan 2 - Java3D
?A sentence is constructed with a series of words? Index 0 1 2 3...JOptionPan 2  A sentence can be thought of as one or more words which... words in total Java has a standard to index elements starting with 0. So the first
Java Programming: Chapter 1 Quiz Answers
Sample Quiz Answers For Chapter 1 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 1 of this on-line Java textbook. Note... language.) Question 5: If you have the source code for a Java program
Java programming 1 - Java Beginners
Java programming 1  Thx sir for reply me ^^ err how bout if using scanner class or further method to solve that code? instead of using array?  ...://www.roseindia.net/java/java-tips/examples-introductory/console/console-input
Features of Jsp 2
are those elements which is used to embed Java code inside the JSP file... that it can be learn without the knowledge of Java. After going through this tutorial... in scriptfree JSP pages: 1). By using a page directive: We can enable EL
Java programming 1 - Java Beginners
Java programming 1  Hi sir, i facing problem in this program....   Hi friend, Please send me full code. Because your.../java/example/java/swing/ Thanks
java 2 - Java Server Faces Questions
java 2  1) a) Write a pseudo code algorithm to pick the 1st element as a pivot and a partitioning array according to the instructions given... and partitioning) to Java. It should be able to execute any set of data. Note:- You should
new 2
(rs.getString(1)); arr2.add(rs.getString(2...new 2  <%@page import="java.util.ArrayList"%> <%@page...; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 sevelet
Java Programming: Chapter 1
Chapter 1 Overview: The Mental Landscape WHEN YOU BEGIN a journey... is and how one is created. Since you will be writing programs in the Java... in particular and about the modern, networked computing environment for which Java
Java: Method Exercises 1
Java NotesMethod Exercises 1 Name: _________________________________ What...? ___________________________ ___________________________ ___________________________ ___________________________ ___________________________ ___________________________ 1 2 3 4 5
data insertion and fetch 1
data insertion and fetch 1  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <...;table border="2"> <th>Name</th>... { /* * TODO output your page here. You may use following sample code
Fwd: Please spend 2 minutes - Java Beginners
Fwd: Please spend 2 minutes  Fresher to Java...getting some problem with getting output for this program 1+1/2+1/3+......+1/n. please if possible send it to me   Hi Friend, Try the following code: import
Echo 2
Echo 2       Echo 2 allows you to code Ajax apps in pure Java (Demo)which automatically generates HTML and Javascript. Read full Description
New Page 1
JavaScript loop through In this Tutorial we want to describe you a code that help you in understanding JavaScript loop through. We are using Java Script...;= 1; i <= 9; i++){   for(var j = 1
What does "1"+2+4 evaluate to?
What does "1"+2+4 evaluate to?  What does "1"+2+4 evaluate
task 2 - Java Beginners
task 2  Write a time server that follows the time protocol outlined in RFC 868. When a client connects, the server sends a 4-byte, big-endian..., January 1, 1970 GMT (the epoch
Moire Pattern 2 Java
Moire Pattern 2 Java   textWhat you are seeing in the screenshot... and height are the same. Make the program from this older code: import...; g2.setColor(Color.black);g2.fillOval(centerX, centerY - ovalWidth / 2, 300, ovalWidth
GUI 2 - Java Beginners
GUI 2  How can I modify this code? Please give me a GUI...); }}//newly added code//KeyEvent function public void numberTextField_KeyTyped...();}}This will help you out..  Brilliant! The keyEvent works, but the modified code
que 2 - Java Beginners
que 2  WAP to input a string & print out the text withthe uppercase & lowercase letters reversed,but all other characters should remain the same..., Try the following code: import java.util.*; class CaseConverter{ public
java bits 1 - Java Interview Questions
java bits 1   Given: 11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12? (Choose three.) A. final B. static C. native D. public E. private F. abstract G
java code
java code  java database code to retrieve data at runtime and please give codes for insert delete too.... using jsp and withot jsp   1... border="1"> <tr><th>Name</th><th>Address</th><
java code
and then download that file using Servlet. 1)page.jsp: <%@ page language="java...java code  Hai,I need to download the data file from database with csv format using java/servlet.I would like to download the csv file when user
java code
. 1)page.jsp <%@ page language="java" %> <Html> <HEAD><...java code  Hai,I need to download the data file from database with csv format using java/servlet.I would like to download the csv file when user
Java: String Exercise 2
Java: String Exercise 2 Name ______________________ Assume the following..., or illegal. 1__________h.length() 2__________h.substring(1) 3__________h.toUpperCase...("c") 19__________"a".compareTo("A") 20__________s.trim().charAt(2) String
Struts 2 Tutorial
to Struts 2 Login Application In this section we will write the code... will see how to write code that will generate Java Script code for client side... to validate your text area in struts 2. A text area contains 1 to 250 characters
Simple Linked List Exercise 1
Java Notes: Simple Linked List Exercise 1 Name: ___________________________________________ Fill in the blanks to for this program that reads strings and puts them in a doubly linked list. 1 2 3 4 5 6 7 8
Struts 2 Login Form Example
. Let's start developing the Struts 2 Login Form Example Step 1...Struts 2 Login Form Example tutorial - Learn how to develop Login form in Struts 2 though this video tutorial In this video tutorial I will explain you how
Struts 2 MySQL
Struts 2 MySQL       In this section, You will learn to connect the MySQL database with the struts 2 application...;         Step 1: Create the struts.xml file and add