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();
---------------------------------------------------------------------------------------------------------------------------------------
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--------------------------------------------------
Write some Java code representing a task from real life, and include a loop and/or collection....
use java code Write a collection of array utility methods. •Write a method to create a list of duplicate numbers in an array. •Write a method to create a list of duplicate Strings in an array. •Convert to using generics.
java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...
5. Write Java code for a loop that simultaneously computes both the maximum and minimum of an array.
In Java code Write a complete method name convertFile that accepts a File object representing an input text file and a PrintWriter objects as arguments. The method should read the contents of the input file and change all characters to uppercase and store the results in the output file.
Java Language Write a complete method calculateCost that accepts two parameters: a char representing package code for photo orders and a char representing a code for extra add- ons. The method returns a double representing the amount of the photo order (base order package order and any add-ons). Compute the amount of the order given the following table of base package codes: $12 $24 $40 $70 Add-on cost for the following codes: $5 n $5 MEN $10 no additional cost
Explain the concept of inheritance in java by providing examples from the real life. You should identify the Superclass and Subclasses in your example
(Java) Write a code segment that uses a for loop and an in a statement to determine whether the value 13 is stored in a previously declared dimensional array named sportsScores. If the value 13 is stored in the array, then store the value true in a boolean flag variable named found. Otherwise, store false in found. The array sportsScores has 4 columns and 5 rows.
How do I write this code from while loop to for loop? (this is the whole code) NOTE: do not add any import other than: import java.util.ArrayList; import java.util.Collection;(collection not collections) import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.HashSet; code: public static int frequency(Collection values, int target) { var iter = values.iterator(); int app = 0; while (iter.hasNext()) { if(iter.next() == target) { app++; } } return app; } public static boolean isSorted(List list) { var iter = list.listIterator(); int...
JAVA Write Java code for extending the LinkedList class of java.util.* to ExtLinkedList that would include the following method: public ExtLinkedList firstHalfList() which returns the first half of the list. In other words, if you have a ExtLinkedList of size 5, for example, the method firstHalfList should return the list with the first two nodes. If it is a list of size 6, it should return the list with the first three nodes. The original list should not be modified....
need java whole code to be executed. in eclipse! Lab task 2 Population of a town today is 100,000. The population has increased steadily at the rate of10% per year for the last 10 years. Write a program to determine and print the population at the end of each year in the last decade. Hint: This problem needs only a single loop. If you complete both of these tasks and submit during lab time then one of your lowest lab...