Question

Write some Java code representing a task from real life, and include a loop and/or collection....

Write some Java code representing a task from real life, and include a loop and/or collection. Example:

for (ClothingItem item : laundry) {
    washer.add(item);
}
washer.setFillLevel("max");
washer.setTemperature("warm");
washer.wash();
0 0
Add a comment Improve this question Transcribed image text
Answer #1

---------------------------------------------------------------------------------------------------------------------------------------

Here is an example of AirConditionr

AC

-----------------------------------------

import java.util.Scanner;


class AC
{
   \\default constructer
   public void AC()
   {}

   \\cooling on
   public void TurnOnCooling()
   {
       System.out.println(" Turned On ");
   }

   \\cooling off
   public void TurnOffCooling()
   {
       System.out.println(" Turned Off ");
   }
}
public class TemperatureConverter {
  


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        AC a=new AC();
        /* Input temperature */
        System.out.print("Enter temperature in Celsius: ");
        float c = in.nextFloat();
      
        if (c>23)
        {
       a.TurnOnCooling();
   }
   else
   {
       a.TurnOffCooling();
   }
    }
}

-------------------------------------------------------------------------------------OUTPUT--------------------------------------------------

Add a comment
Know the answer?
Add Answer to:
Write some Java code representing a task from real life, and include a loop and/or collection....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT