1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Shalnov [3]
3 years ago
12

You are developing a system to process lists of days of the week, represented as strings. Create a function is_weekend that cons

umes a list and returns whether the list has the string "Saturday" or the string "Sunday" in it. Call and print this function once with a list of days of the week.
Computers and Technology
1 answer:
Dafna11 [192]3 years ago
5 0

Answer:

   public static boolean is_weekend(List week){

       if(week.contains("Saturday")||week.contains("Sunday"))

       {

           System.out.println("List has a weekend");

           return true;

       }

       else{

           System.out.println("List has no weekend");

           return false;

       }

   }

Explanation:

  • Using java programming language
  • Import <em>java.util.ArrayList</em> and <em>import java.util.List;</em> so you can implement a java list
  • Create a list and add the days of the week
  • Create the required method using the contains() method to check for Sunday and Saturday and return true if the list contains them
  • See the complete program with a call to the method

<em>import java.util.ArrayList;</em>

<em>import java.util.List;</em>

<em>public class Car {</em>

<em>    public static void main(String[] args) {</em>

<em>        List<String> daysOfWeek = new ArrayList<>();</em>

<em>        daysOfWeek.add("Sunday");</em>

<em>        daysOfWeek.add("Moday");</em>

<em>        daysOfWeek.add("Tuesday");</em>

<em>        daysOfWeek.add("Wednesday");</em>

<em>        daysOfWeek.add("Thursday");</em>

<em>        daysOfWeek.add("Friday");</em>

<em>        daysOfWeek.add("Saturday");</em>

<em>        is_weekend(daysOfWeek);</em>

<em>    }</em>

<em>    public static boolean is_weekend(List week){</em>

<em>        if(week.contains("Saturday")||week.contains("Sunday"))</em>

<em>        {</em>

<em>            System.out.println("List has a weekend");</em>

<em>            return true;</em>

<em>        }</em>

<em>        else{</em>

<em>            System.out.println("List has no weekend");</em>

<em>            return false;</em>

<em>        }</em>

<em>    }</em>

}

You might be interested in
Which statement describes what the Conditional Formatting option in Excel 2016 allows users to do?
jeyben [28]

Answer:

It automatically applies formatting based on specific rules or conditions being met. It automatically applies highlighting to selected cell ranges based on specific rules or conditions being met.

Explanation:

6 0
3 years ago
Read 2 more answers
bro i got banned for posting an amazing bulk pic, but this dude literally posted an inappropriate, dafuq is wrong with this bann
Ludmilka [50]

Answer:

okkk

Explanation:

5 0
3 years ago
Read 2 more answers
Redesign the cover of science textbook using at least two different graphics​
Tanya [424]

Answer:

what design do you want, also what design am i redesigning.

8 0
2 years ago
What are some of the benefits of project
galina1969 [7]

Answer:

The project is more likely to be finished on  time.

Tasks can be done more efficiently.

Explanation:

Project management refers to the process involved in the management and accomplishment of the project. It includes the process, techniques, and guidance to carry on to complete a project. Project management helps in achieving the desired outcomes of the project. The efficient use of the resources and the proper management of the skills are ensured in project management. Better communication and an increase in satisfaction help in improving productivity.

4 0
3 years ago
What is the name of the User-defined function that is mentioned in the code?
Marizza181 [45]

The name of the user defined function is: footballMatch

6 0
3 years ago
Other questions:
  • Your assignment is to write an assembly language program which read a string and print it in uppercase. This program asks the us
    15·1 answer
  • Suppose arraylist list1 is [1, 2, 5] and arraylist list2 is [2, 3, 6]. after list1.addall(list2), list1 is __________.
    8·1 answer
  • Select the correct answer.
    8·2 answers
  • . Virtualization simplifies the use of resources, isolates users from one another, supports replication and mobility, but exacts
    7·1 answer
  • The _device provides a means of communication between a computer and outer world.​
    14·1 answer
  • What is Quantum Cryptography? How is it different from Public and Private-key transactions?
    6·1 answer
  • A _____ are devices that permit a user to connect to a digital t-carrier service.
    6·1 answer
  • I have a question. This question will probably be deleted, but why do moderators keep deleting my answers when they are legitima
    13·1 answer
  • Select the correct answer.
    9·1 answer
  • Which of these is a neologism created as a result of the information age?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!