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]
2 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]2 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
In c++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value.
sergiy2304 [10]
<span>In describing an Initialization is when a value is assigned to a variable as part of the variable's definition or the assinged values to variables are defined whenever. 

The best answer would be is that they present the keyword,  when they tell the compiler.</span>
3 0
3 years ago
Tab stops are very useful when you want to A. align text into rows. B. add space between paragraphs. C. align text into columns.
Alenkasestr [34]
The best answer here is Answer C - Tab stops are useful when you want to "align text into columns".

All tab stops do is shift text a fixed amount to the left or right on the line. They are useful for improving the layout of text when you want to align multiple rows.

Answer A is incorrect because rows are vertical and not horizontal. B is also irrelevant because spaces between paragraphs are vertical. Answer D could also be correct because you can use tab stops to indent text aswell, but the more general answer is A. If you can have more than one answer, you could have A and D.
8 0
3 years ago
Read 2 more answers
A species of snake lives in a rainforest. Which would be an adaptation for this
raketka [301]

Answer:

The Answer is D

6 0
3 years ago
Read 2 more answers
To specify your preferred colors, fonts, and effects for a document, which of the following should be done?
Irina-Kira [14]

Answer: crest custom theme

Explanation:

8 0
2 years ago
Read 2 more answers
This tag is used to change the appearance of your text on your web page
zaharov [31]

Answer:

b.font tag

is used to change the appearance of your text on your web page

8 0
3 years ago
Other questions:
  • Define a function CoordTransform() that transforms its first two input parameters xVal and yVal into two output parameters xValN
    7·2 answers
  • Write a for loop to verify that your function is correctly returning the expected output for the radius values between 0 and 11.
    14·1 answer
  • Please Do Solve it guys...
    6·1 answer
  • "_____ devices improve memory by encoding items in a special way."
    13·1 answer
  • What is it called when two different files generate the same hashing result?
    15·1 answer
  • How many of you got the right answer from this app​
    8·1 answer
  • The question of ________ arises when considering the way in which online marketers gather consumers’ information over the Intern
    6·1 answer
  • Tại sao xe chỉ sản xuất ra 1996cc mà không phải là 2000cc?
    6·2 answers
  • THIS IS TIMED PLS HURRY UP
    7·1 answer
  • Is TCP really more secure than other L4 protocols by default?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!