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
On the 74ls74 d flip-flop, the clk input has a small triangle. the pr (preset) and clr (clear) inputs have a circle. what do the
topjm [15]
The triangle indicates that the clock signal is an edge-triggered signal.
The circle indicates that the signal is low-active (ie., inverted).
The 74LS74 has a positive-edge trigger clock (low to high).
7 0
3 years ago
What is an advantage of a computer network ? networked
sergij07 [2.7K]

1. Data is easy to backup as all data is stored on the file server.

2.Network users can communicate by email and instant messenger.

5 0
3 years ago
Read 2 more answers
Can someone that been helping me answer one more question for please and thx
Gnom [1K]

Answer:

D

Explanation:

Federal Tax, not state

5 0
3 years ago
What is the default setting Excel shows when Insert is clicked?
NikAS [45]

Answer: entire column

7 1
3 years ago
Read 2 more answers
when a picture is downloaded off the internet and then posted to social media, can the social media platform tell it was downloa
Nataly_w [17]
Short answer yes. kinda long answer people can scan the photo and easily see or they can just look up the same image
4 0
3 years ago
Other questions:
  • Heatsinks used to protect cpus in computers from overheating, are shaped so that their surface area is very large. why is that?
    5·1 answer
  • Why is the keyboard arranged in the QWERTY style?
    6·2 answers
  • What is a seismogram?
    9·1 answer
  • Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bits memory address r
    9·1 answer
  • A third-grade teacher at Potter Elementary School wants a program that allows a student to enter the amount of money a customer
    14·1 answer
  • Translation of a file into a coded format that occupies less space than the original file is called
    15·1 answer
  • Which style did Jack use on the vocabulary words in reports?
    14·2 answers
  • In order to enhance the training experience and emphasize the core security goals and mission, it is recommended that the execut
    5·1 answer
  • What is string literal in Java?
    5·1 answer
  • Your development team is planning to host a development environment on the cloud. This consists of EC2 and RDS instances. This e
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!