Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a newline and decare/use loop variable. Example output for numCycles = 2:
1: Lather and rinse.
2: Lather and rinse.
Done.
import java.util.Scanner; 3 public class ShampooBottle 4 5 Your solution goes here / 7 public static void main (String [] args) ShampooBottle trialSize - new ShampooBottle); trialsize.printShampooInstructions (2) 10 Run View your last submission Your solution goes here / public void printShampooInstructions (int numCycles) f if (numCycles 1) System.out.printin("Too few.") else if (numCycles4) System.out.printin("Too many.") else System.out.println("Done."); for (int i = 1; i (z numCycles ; ++i){ System.out . printin (? + ": Lather and rinse.");

Answers

Answer 1

Answer:

if (numCycles < 1){

        System.out.println("Too few.");

     }

     else if (numCycles > 4){

        System.out.println("Too many.");

        }    

  else{

     for(int i = 1; i <= numCycles; i++)

  {

     System.out.println(i + ": Lather and rinse.");

  }

     System.out.println("Done.");

  }

 

Explanation:


Related Questions

1. Describe data and process modeling concepts and tools.

Answers

Answer:

data is the raw fact about its process

Explanation:

input = process= output

data is the raw fact which gonna keeps in files and folders. as we know that data is a information keep in our device that we use .

Answer:

Data and process modelling involves three main tools: data flow diagrams, a data dictionary, and process descriptions. Describe data and process tools. Diagrams showing how data is processed, transformed, and stored in an information system. It does not show program logic or processing steps.

When implementing a 1:1 relationship, where should you place the foreign key if one side is mandatory and one side is optional? Should the foreign key be mandatory or optional?

Answers

Answer:

When implementing a 1:1 relationship, the foreign key should be placed on the optional side if one side is mandatory and one side is optional.  

When this is implemented, the foreign key should be made mandatory.

Explanation:

A foreign key (FK) is a primary key (PK) in relational databases.  It is used to establish a relationship with a table that has the same attribute with another table in the database.  A mandatory relationship exists when the foreign key depends on the parent (primary key) and cannot exist without the parent.  A one-to-one relationship exists when one row in a data table may be linked with only one row in another data table.

provides an automated method for discovering host systems on a network. Although it doesn't necessarily discover all weaknesses, it does determine which systems are active on the network and what services they offer or what ports are available

Answers

Answer:

Network scan

Explanation:

Cyber security can be defined as preventive practice of protecting computers, software programs, electronic devices, networks, servers and data from potential theft, attack, damage, or unauthorized access by using a body of technology, frameworks, processes and network engineers.

Some examples of cyber attacks are phishing, zero-day exploits, denial of service, man in the middle, cryptojacking, malware, SQL injection, spoofing etc.

Generally, a security assessment is carried out by network security experts on a regular basis to determine potential loopholes or vulnerabilities in the information and technology (IT) infrastructure. One of the techniques or approach used in security assessment is a network scan.

A network scan is a security assessment technique used for the automatic detection of host systems on a network. Although a network scan isn't capable of discovering or detecting all the weaknesses on a network, it avails users information about the computer systems that are active on the network and what services the computer systems offer or what ports are available on them.

What are the LinkedIn automation tools you are using?

Answers

Answer:

Well, for me I personally use LinkedCamap to drive more LinkedIn connections, hundreds of leads, sales, and conversions automatically.

Some other LinkedIn automation tools are;

ExpandiMeet AlfredPhantombusterWeConnectLinkedIn Helper

Hope this helps!

The computer that is used in scientific research is ........​

Answers

Answer:

supercomputers are the computer that is used in scientific research.

Answer:

super computer is the right answer

Write a program named edit_data.py that asks a person their age. Accept an int. Use a custom exception to return a message if the number entered is an int that is less than 1 or greater than 115. Create an exception that catches an error if a non int is entered.

Answers

An exception is an error that happens during the execution of a program. Exceptions are known to non-programmers as instances that do not conform to a general rule. The name "exception" in computer science has this meaning as well: It implies that the problem (the exception) doesn't occur frequently, i.e. the exception is the "exception to the rule". Exception handling is a construct in some programming languages to handle or deal with errors automatically. Many programming languages like C++, Objective-C, PHP, Java, Ruby, Python, and many others have built-in support for exception handling.

Error handling is generally resolved by saving the state of execution at the moment the error occurred and interrupting the normal flow of the program to execute a special function or piece of code, which is known as the exception handler. Depending on the kind of error ("division by zero", "file open error" and so on) which had occurred, the error handler can "fix" the problem and the programm can be continued afterwards with the previously saved data.

An error that occurs while a program is being run is an exception. Non-programmers see exceptions as examples that do not follow a general rule.

What is the programming?


In computer science, the term "exception" also has the following connotation: It signifies that the issue is an uncommon occurrence; it is the "exception to the rule." Some programming languages use the mechanism known as exception handling to deal with problems automatically. Exception handling is built into several programming languages, including C++, Objective-C, PHP, Java, Ruby, Python, and many others.

In order to manage errors, programs often save the state of execution at the time the problem occurred and interrupt their usual operation to run an exception handler, which is a particular function or section of code. Depending on the type of error that had occurred, the error handler can "correct" the issue and the application can then continue using the previously saved data.

Thus, An error that occurs while a program is being run is an exception.

For more information about programming, click here:

https://brainly.com/question/11023419

#SPJ5

Which operating system desktop or mobile is the best

Answers

Answer:

bing or alien ware is the best.

Answer:

Your choice, but personally, desktop is better.

Explanation:

Desktop devices have portrait orientations so content can stretch across a screen and often multiple messages or images can live comfortably in such a wide space. Mobile devices are usually used in portrait orientation (and the smaller screens mean that even in landscape mode, horizontal space is limited).

Explain why interrupt times and dispatch delays must be limited to a hard real-time system?

Answers

Answer:

The important problem is explained in the next section of clarification.

Explanation:

The longer it is required for a computing device interrupt to have been performed when it is created, is determined as Interrupt latency.

The accompanying duties include interrupt transmission delay or latency are provided below:

Store the instructions now being executed.Detect the kind of interruption.Just save the present process status as well as activate an appropriate keep interrupting qualitative functions.

I need the SQL statements for these questions:
1. For each reservation, list the reservation ID, trip ID, customer number, and customer last name. Order the results by customer last name.
2. For each reservation for customer Ryan Goff, list the reservation ID, trip ID, and number of persons.
3. List the trip name of each trip that has Miles Abrams as a guide.
4. List the trip name of each trip that has the type Biking and that has Rita Boyers as a guide.
5. For each reservation that has a trip date of July 23, 2016, list the customer’s last name, the trip name, and the start location.
6. List the reservation ID, trip ID, and trip date for reservations for a trip in Maine (ME). Use the IN operator in your query.
7. Repeat Exercise 6, but this time use the EXISTS operator in your query.
8. Find the guide last name and guide first name of all guides who can lead a paddling trip. (Note: The query results should include duplicate values.)
Here are the tables:
CUSTOMER FIRST NAME POSTAL CODE CUSTOMER NUM LAST NAME ADDRESS Northfold Liam 9 Old Mill Rd Londonderry 10 NH 03053 103 Kasuma Sujata 132 Main St. #1 East Hartford CT 06108 MA 01854 Goff 164A South Bend Rd. Lowell Ryan 105 McLean Kyle 345 Lower Ave. Wolcott NY 14590 106 Morontoia Joseph 156 Scholar St Johnston 02919 107 Marchand Quinn 76 Cross Rd Bath NH 03740 108 32 Sheep stop St Edinboro PA Rulf Usch 16412 109 Caron Jean Luc 10 Greenfield St Rome ME 04963 110 Martha York Bers 65 Granite St NY 14592 112 Jones Laura 373 Highland Ave. Somerville MA 02143 115 Nu Adam 1282 Ocean Walk Ocean City Vaccari 08226 116 Murakami Iris 7 Cherry Blossom St. Weymouth MA 02188 119 Londonderry vT Chau 18 Ark Ledge Ln Clement 05148 120 Gernowski Sadie 24 stump Rd. Athens ME 04912 121 Cambridge VT Bretton-Borak Siam 10 Old Main St 122 Hefferson orlagh 132 South St. Apt 27 Manchester NH 03101 123 25 Stag Rd Fairfield Barnett Larry 06824 124 Busa Karen 12 Foster St. South Windsor CT 06074 125 51 Fredrick St Albion Peterson Becca NY 14411 126 Brown Brianne 154 Central St Vernon CT 06066 PHONE Click to Add 603-555-7563 413-555-3212 860-555-0703 781-555-8423 585-555-5321 401-555-4848 603-555-0456 814-555-5521 207-555-9643 585-555-0111 857-555-6258 609-555-5231 617-555-6665 802-555-3096 207-555-4507 802-555-3443 603-555-3476 860-555-9876 857-555-5532. 585-555-0900 860-555-3234

Answers

Answer:

Explanation:

/* From the information provided, For now will consider the name of table as TRIPGUIDES*/

/*In all the answers below, the syntax is based on Oracle SQL. In case of usage of other database queries, answer may vary to some extent*/

1.

Select R.Reservation_ID, R.Trip_ID , C.Customer_Num,C.Last_Name from Reservation R, Customer C where C.Customer_Num=R.Customer_Num ORDER BY C.Last_Name

/*idea is to select the join the two tables by comparing customer_id field in two tables as it is the only field which is common and then print the desired result later ordering by last name to get the results in sorted order*/

2.

Select R.Reservation_ID, R.Trip_ID , R.NUM_PERSONS from Reservation R, Customer C where C.Customer_Num=R.Customer_Num and C.LAST_NAME='Goff' and C.FIRST_NAME='Ryan'

/*Here, the explaination will be similar to the first query. Choose the desired columns from the tables, and join the two tables by equating the common field

*/

3.

Select T.TRIP_NAME from TRIP T,GUIDE G,TRIPGUIDES TG where T.TRIP_ID=TG.TRIP_ID and TG.GUIDE_NUM=G.GUIDE_NUM and G.LAST_NAME='Abrams' and G.FIRST_NAME='Miles'

/*

Here,we choose three tables TRIP,GUIDE and TRIPGUIDES. Here we selected those trips where we have guides as Miles Abrms in the GUIDES table and equated Trip_id from TRIPGUIDES to TRIP.TRIP_Name so that can have the desired results

*/

4.

Select T.TRIP_NAME

from TRIP T,TRIPGUIDES TG ,G.GUIDE

where T.TRIP_ID=TG.TRIP_ID and T.TYPE='Biking' and TG.GUIDE_NUM=G.GUIDE_NUM and G.LAST_NAME='Boyers' and G.FIRST_NAME='Rita'

/*

In the above question, we first selected the trip name from trip table. To put the condition we first make sure that all the three tables are connected properly. In order to do so, we have equated Guide_nums in guide and tripguides. and also equated trip_id in tripguides and trip. Then we equated names from guide tables and type from trip table for the desired results.

*/

5.

SELECT C.LAST_NAME , T.TRIP_NAME , T.START_LOCATION FROM CUSTOMER C, TRIP T, RESERVATION R WHERE R.TRIP_DATE='2016-07-23' AND T.TRIP_ID=R.TRIP_ID AND C.CUSTOMER_NUM=R.CUSTOMER_NUM

/*

The explaination for this one will be equivalent to the previous question where we just equated the desired columns where we equiated the desired columns in respective fields and also equated the common entities like trip ids and customer ids so that can join tables properly

*/

/*The comparison of dates in SQL depends on the format in which they are stored. In the upper case if the

dates are stored in the format as YYYY-MM-DD, then the above query mentioned will work. In case dates are stored in the form of a string then the following query will work.

SELECT C.LAST_NAME , T.TRIP_NAME , T.START_LOCATION FROM CUSTOMER C, TRIP T, RESERVATION R WHERE R.TRIP_DATE='7/23/2016' AND T.TRIP_ID=R.TRIP_ID AND C.CUSTOMER_NUM=R.CUSTOMER_NUM

*/

6.

Select R.RESERVATION_ID, R.TRIP_ID,R.TRIP_DATE FROM RESERVATION R WHERE R.TRIP_ID IN

{SELECT TRIP_ID FROM TRIP T WHERE STATE='ME'}

/*

In the above question, we firstly extracted all the trip id's which are having locations as maine. Now we have the list of all the trip_id's that have location maine. Now we just need to extract the reservation ids for the same which can be trivally done by simply using the in clause stating print all the tuples whose id's are there in the list of inner query. Remember, IN always checks in the set of values.

*/

7.

Select R.RESERVATION_ID, R.TRIP_ID,R.TRIP_DATE FROM RESERVATION WHERE

EXISTS {SELECT TRIP_ID FROM TRIP T WHERE STATE='ME' and R.TRIP_ID=T.TRIP_ID}

/*

Unlike IN, Exist returns either true or false based on existance of any tuple in the condition provided. In the question above, firstly we checked for the possibilities if there is a trip in state ME and TRIP_IDs are common. Then we selected reservation ID, trip ID and Trip dates for all queries that returns true for inner query

*/

8.

SELECT G.LAST_NAME,G.FIRST_NAME FROM GUIDE WHERE G.GUIDE_NUM IN

{

SELECT DISTINCT TG.GUIDE_NUM FROM TRIPGUIDES TG WHERE TG.TRIPID IN {

SELECT T.TRIP_ID FROM TRIP T WHERE T.TYPE='Paddling'

}

}

/*

We have used here double nested IN queries. Firstly we selected all the trips which had paddling type (from the inner most queries). Using the same, we get the list of guides,(basically got the list of guide_numbers) of all the guides eds which were on trips with trip id we got from the inner most queries. Now that we have all the guide_Nums that were on trip with type paddling, we can simply use the query select last name and first name of all the guides which are having guide nums in the list returned by middle query.

*/

Sophia is putting together a training manual for her new batch of employees.Which of the following features can she use to add a document title at the top of each page?
A) Heading style
B) Page margin
C) References
D) Header and Footer

Answers

Answer:

A heading style to add a document title

The feature can she use to add a document title at the top of each page is - Heading style. Therefore option A is the correct resposne.

What are Header and Footer?

A footer is a text that is positioned at the bottom of a page, whereas a header is text that is positioned at the top of a page. Usually, details about the document, such as the title, chapter heading, page numbers, and creation date, are inserted in these spaces.

A piece of the document that appears in the top margin is called the header, while a section that appears in the bottom margin is called the footer. Longer papers may be kept structured and made simpler to read by including more information in the headers and footers, such as page numbers, dates, author names, and footnotes. Each page of the paper will have the header or footer text you input.

To read more about Header and Footer, refer to - https://brainly.com/question/20998839

#SPJ2

Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6, 7, 7, 12, then isSorted(a, 5) should return 1 . If array b stores 3, 4, 9, 8, then isSorted(b, 4) should return 0.

Answers

Answer:

The function in C++ is as follows:

int isSorted(int ar[], int n){

if ([tex]n == 1[/tex] || [tex]n == 0[/tex]){

 return 1;}

if ([tex]ar[n - 1][/tex] < [tex]ar[n - 2][/tex]){

 return 0;}

return isSorted(ar, n - 1);}

Explanation:

This defines the function

int isSorted(int ar[], int n){

This represents the base case; n = 1 or 0 will return 1 (i.e. the array is sorted)

if ([tex]n == 1[/tex] || [tex]n == 0[/tex]){

 return 1;}

This checks if the current element is less than the previous array element; If yes, the array is not sorted

if ([tex]ar[n - 1][/tex] < [tex]ar[n - 2][/tex]){

 return 0;}

This calls the function, recursively

return isSorted(ar, n - 1);

}

Choose all that Apply: Which of the following steps should be performed by the CIS for creating a part dispatch for systemboard through Tech Direct?
a) Enter the customer's contact and email address into the primary contact fields when requesting a systemboard through TechDirect
b) Logging fusion ticket to request DPK via DDL
c) Access the customer's DDL account to retrieve DPK and activate the os for the customer
d) Verify the customer email address

Answers

Answer:

The steps that should be performed by the CIS for creating a part dispatch for system board through TechDirect are:

a) Enter the customer's contact and email address into the primary contact fields when requesting a system board through TechDirect

b) Logging fusion ticket to request DPK via DDL

c) Access the customer's DDL account to retrieve DPK and activate the os for the customer

d) Verify the customer email address

Explanation:

The four steps given above must be performed in the CIS if you want to create a part dispatch for the system board through TechDirect.  TechDirect is a support system that enables one to manage all Dell technologies from a single location. After creating the part dispatch, the customer's contact and email address are entered into the primary contact fields to enable the verification of the customer's email address  through the TechDirect.

1. Write the CSS for an id with the following characteristics: fixed position, light grey background color, bold font weight, and 10 pixels of padding

Answers

Answer:

#element

{

position: fixed;

background-color: RGBA(211, 211, 211, 1);

font-weight: bold;

padding: 10px;  

}

Which of the following terms describes an attacker walking or driving through business areas and neighborhoods to identify unprotected wireless networks from the street using a laptop or a handheld computer?
A. Wi-Fi stealing.
B. Wi-Fi trolling.
C. Wi-Fi jacking.
D. Wi-Fi hacking.

Answers

Answer:

C. Wi-Fi jacking

Explanation:

Answer: yessir b

Explanation:

The valid call to the function installApplication is

void main(  )
{
 // call the function installApplication
}

void installApplication(char appInitial, int appVersion)
{
  // rest of function not important
}

Answers

Answer:

B. installApplication(‘A’, 1);

Explanation:

Given

The above code segment

Required

The correct call to installApplication

The function installApplication is declared as void, meaning that it is not expected to return anything.

Also, it receives a character and an integer argument.

So, the call to this function must include a character and an integer argument, in that order.

Option D is incorrect because both arguments are integer

Option C is incorrect because it passes no argument to the function.

Option A is incorrect because it receives an integer value from the function (and the function is not meant not to have a return value).

Option B is correct

Suppose during a TCP connection between A and B, B acting as a TCP receiver, sometimes discards segments received out of sequence, but sometimes buffers them. Would the data sent by A still be delivered reliably and in-sequence at B? Explain why.

Answers

Answer:

Yes

Explanation:

We known that TCP is the connection [tex]\text{oriented}[/tex] protocol. So the TCP expects for the target host to acknowledge or to check that the [tex]\text{communication}[/tex] session has been established or not.

Also the End stations that is running reliable protocols will be working together in order to verify transmission of data so as to ensure the accuracy and the integrity of the data. Hence it is reliable and so the data can be sent A will still be delivered reliably and it is in-sequence at B.

The message signal m(t) = 10cos(1000t) frequency modulates the carrier c(t) = 10cos(2fct). The modulation index is 10.
1) Write an expression for the modulated signal u(t).
2) What is the power of the modulated signal.
3) Find the bandwidth of the modulated signal.

Answers

Answer:

1) 10cos ( 2πfct + 10sin 2πfmt )

2) 50 watts

3) 1000 Hz

Explanation:

m(t) = 10cos(1000πt)

c(t) = 10cos(2πfct )

modulation index (  = 10

1) expression for modulated signal ( u(t) )

u(t) = Ac(cos 2πfct ) + A (cos 2πfct m(t) ) Am cos2πf mt

      = 10cos 2πfct + 100 cos 2πfct  cos2π500t

      = 10cos ( 2πfct + 10sin 2πfmt )

2) power of modulated signal

power of modulated signal  μ^2 / 2 ]

           = 10^2/2 ]

           = 50 watts

3) Bandwidth

B = 2fm  = 2 * 500 = 1000 Hz

How can an Outlook user search for contacts? Check all that apply.

the Search bar located above the list of contacts
the Search People bar on the Find command group
the Search People located on the People navigation icon
CTL + E to activate the search contacts box
advanced Find under the Search tab
the options menu in the backstage view

Answers

Answer: the Search bar located above the list of contacts.

the Search People bar on the Find command group.

the Search People located on the People navigation icon.

CTL + E to activate the search contacts box.

advanced Find under the Search tab.

Explanation:

An Outlook user can search for contacts through the following ways:

• the Search bar located above the list of contacts.

• the Search People bar on the Find command group.

• the Search People located on the People navigation icon.

• CTL + E to activate the search contacts box.

• advanced Find under the Search tab.

Therefore, the correct options are A, B, C, D and E.

Draw a Card. Write a program to simulate drawing a card. Your program will randomly select one card from a deck of 52 playing cards. Your program should display the rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card. Here is a sample run of the program: in The card you picked is Jack of Heart The program should use at a minimum: sequence, selection, arrays, and random numbers.

Answers

Answer:

Explanation:

The following code is written in Java. It is a function that creates a Random object to generate random values, then uses those values to choose a random rank and suit using switch statements. It then saves the rank and suit into a String variable in the correct format and finally prints the card that was picked to the screen. The function was called 4 times in the main method and the output can be seen in the attached image below.

public static void randomCardGenerator() {

       Random rand = new Random();

       int rank = rand.nextInt(14)+1;

       int suit = rand.nextInt(4)+1;

       String chosenCard = "";

       switch (rank) {

           case 1: chosenCard += "Ace"; break;

           case 2: chosenCard += "1"; break;

           case 3: chosenCard += "2"; break;

           case 4: chosenCard += "3"; break;

           case 5: chosenCard += "4"; break;

           case 6: chosenCard += "5"; break;

           case 7: chosenCard += "6"; break;

           case 8: chosenCard += "7"; break;

           case 9: chosenCard += "8"; break;

           case 10: chosenCard += "9"; break;

           case 11: chosenCard += "10"; break;

           case 12: chosenCard += "Jack"; break;

           case 13: chosenCard += "Queen"; break;

           case 14: chosenCard += "Kind"; break;

           default: System.out.println("Wrong Value");

       }

       chosenCard += " of ";

       switch (suit) {

           case 1: chosenCard += "Clubs"; break;

           case 2: chosenCard += "Diamonds"; break;

           case 3: chosenCard += "Hearts"; break;

           case 4: chosenCard += "Spades"; break;

           default: System.out.println("Invalid Suit");

       }

       System.out.println(chosenCard);

   }

Which statement describes data-sharing in a blockchain?

Answers

Answer:

wheres the statement

Explanation:

For the following 4-bit operation, assuming these register are ONLY 4-bits in size, which status flags are on after performing the following operation? Assume 2's complement representation. 1010+0110
a) с
b) Z
c) N

Answers

Answer:

All flags are On ( c, z , N  )

Explanation:

Given data:

4-bit operation

Assuming 2's complement representation

Determine status flags that are on after performing 1010+0110

    1   1

    1  0   1  0

    0  1   1  0

  1  0 0 0 0

we will carry bit = 1 over

hence C = 1

given that: carry in = carry out there will be zero ( 0 ) overflow

hence V = 0

also Z = 1      

But the most significant bit is  N = 1

What type of device is a computer? Where does it use​

Answers

Answer:A computer is an electronic device that manipulates information, or data. It has the ability to store, retrieve, and process data. You may already know that you can use a computer to type documents, send email, play games, and browse the Web.

Can anyone decipher these? There a bit random. Maybe binary but if there are other ways please include them.​

Answers

Answer:

Explanation:

so this is what "format" is about,   it's saying what do the ones and zeros represent.   b/c the bits can represent lots of different things ,  like letters with ascii code ,   and that's got several types.  some are 8 bits,  some are 16 bits,  the questions  you've shown are in groups of 5 which is really not a "thing" in binary,  it's always by twos,   without some type of  "frame work"  around the bits, we won't know what they represent,  if that is helping?   the important part is what is the "frame work"   that these bits are in.

all of your questions seem to have some  "art"  thing going on,  they make some kinda of binary artwork,  for what they are saying, that's not what's important.  Other than if they form  palindromes,   maybe that's what the questions are really about, how these do from palindromes, that is, they read the same backwards as forwards... I know.. why would anyone read backwards.. but a computer can do that pretty quickly,  sooo sometimes to check,  it will read  forwards and backwards.. but when there is a palindrome,  the computer is "confused"  

this is also a big big part of  "typing"  not like on a keyboard but when you program, and you say that  your variables are of a certain type,  like a char, or a string, or a double, you are specifying how many bits will be used to represent your data.  so then when you put the ones and zeros into the memory ,  ( think RAM)  then it's stored in groups of what ever size you've determined.    hmmmm   does this help?

..............is a piece of hardware used to provide data and instructions to a computer used for interaction and control. *
Output device.
Processing.
input device.
All of above. ​

Answers

Answer:

output

Explanation:

it can be seen and touched

/*
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region .
For example,
X X X X
X O O X
X X O X
X O X X
After running your function, the board should be:
X X X X
X X X X
X X X X
X O X X
*/
public class Solution {
// This algorithm cannot solve the large test set
public void solve(char[][] board) {
// Start typing your Java solution below
// DO NOT write main() function
int rows = board.length;
if(rows == 0) return;
int cols = board[0].length;
for(int i = 0; i < cols; i++) {
// check first row's O
if(board[0][i] == 'O') {
// change it to other symbol
board[0][i] = '#';
dfs(board, 0, i);
}
// check the last row
if(board[rows - 1][i] == 'O') {
board[rows - 1][i] = '#';
dfs(board, rows - 1, i);
}
}
for(int i = 0; i < rows; i++) {
// check first col
if(board[i][0] == 'O') {
board[i][0] = '#';
dfs(board, i, 0);
}
// check last col
if(board[i][cols - 1] == 'O') {
board[i][cols - 1] = '#';
dfs(board, i, cols - 1);
}
}
// change O to X
changeTo(board, 'O', 'X');
// change # to O
changeTo(board, '#', 'O');
return;
}
public void dfs(char[][] board, int row, int col) {
// check up
if(row > 0) {
if(board[row - 1][col] == 'O') {
board[row - 1][col] = '#';
dfs(board, row - 1, col);
}
}
// check left
if(col > 0) {
if(board[row][col - 1] == 'O') {
board[row][col - 1] = '#';
dfs(board, row, col - 1);
}
}
// check right
if(row < board.length - 1) {
if(board[row + 1][col] == 'O') {
board[row+1][col] = '#';
dfs(board, row+1, col);
}
}
// check down
if(col < board[0].length - 1) {
if(board[row][col+1] == 'O'){
board[row][col+1] = '#';
dfs(board, row, col+1);
}
}
return;
}
public void changeTo(char[][] board, char from, char to) {
for(int i = 0; i < board.length; i++) {
for(int j = 0; j < board[0].length; j++) {
if(board[i][j] == from) {
board[i][j] = to;
}
}
}
return;
}
}

Answers

I believe the answer is DN

Please use thread to complete the following program: one process opens a file data.txt, then creates a thread my_thread. The job of the thread my_thread is to count how many lines exist in the file data.txt, and return the number of lines to the calling process. The process then prints this number to the screen.
Basically, you need to implement main_process.c and thread_function.c.
Basic structure of main_process.c:
int main ()
{
Open the file data.txt and obtain the file handler fh;
Create a thread my_thread using pthread_create; pass fh to my_thread;
Wait until my_thread terminates, using pthread_join;
Print out how many lines exist in data.txt.}
Basic structure of thread_function.c:
void *count_lines(void *arg)
{
Obtain fh from arg;
Count how many lines num_lines exist in fh;
Close fh;
Return num_lines
}

Answers

Answer:

Here is the code:-

//include the required header files

#include<stdio.h>

#include<pthread.h>

// method protocol definition

void *count_lines(void *arg);

int main()

{

    // Create a thread handler

    pthread_t my_thread;

    // Create a file handler

    FILE *fh;

    // declare the variable

    int *linecnt;

    // open the data file

    fh=fopen("data.txt","r");

// Create a thread using pthread_create; pass fh to my_thread;

    pthread_create(&my_thread, NULL, count_lines, (void*)fh);

    //Use pthread_join to terminate the thread my_thread

    pthread_join( my_thread, (void**)&linecnt );

    // print the number of lines

printf("\nNumber of lines in the given file: %d \n\n", linecnt);

    return (0);

}

// Method to count the number of lines

void *count_lines(void *arg)

{

    // variable declaration and initialization

    int linecnt=-1;

    char TTline[1600];

    //code to count the number of lines

    while(!feof(arg))

    {

         fgets(TTline,1600,arg);

         linecnt++;

    }

    pthread_exit((void *)linecnt);

    // close the file handler

    fclose(arg);

}

Explanation:

Program:-

LAB: Count multiples (EO)
Complete a program that creates an object of the Count class, takes three integers as input: low, high, and x, and then calls the countMultiples() method. The countMultiples() method then returns the number of multiples of x between low and high inclusively.
Ex: If the input is:
1 10 2
countMutiples() returns and the program output is:
5
Hint: Use the % operator to determine if a number is a multiple of x. Use a for loop to test each number between low and high.
Note: Your program must define the method:
public int countMultiples(int low, int high, int x)
Count.java
1 import java.util.Scanner;
2
3 public class Count {
4
5 public int countMultiples(int low, int high, int x) {
6 /* Type your code here. */
7
8 }
9
10 public static void main(String[] args) {
11 Scanner scnr = new Scanner(System.in);
12 /* Type your code here. */
13 }
14)
15

Answers

Following are the Java Program to the given question:

import java.util.Scanner; //import package for user-input

public class Count  //defining a class Count  

{

   public static int countMultiples(int low,int high,int x)//defining a method countMultiples that takes three integer parameters

   {  

       int c=0,i; //defining integer variables that hold value

       for(i=low;i<=high;i++)//defining loop that iterates value between low and high  

       {  

           if(i%x==0)//defining if block that uses % operator to check value

           {

               c+=1; //incrementing c value

           }

       }

       return c; //return c value

   }

   public static void main(String[] args)//main method  

   {  

       int l,h,x;//defining integer variable

       Scanner scnr=new Scanner(System.in); //creating scanner class object  

       l=scnr.nextInt(); //input value

       h=scnr.nextInt();//input value

       x=scnr.nextInt();//input value

       System.out.println(countMultiples(l,h,x)); //calling method and print its value

   }

}

Output:

Please find the attached file.

Program Explanation:

Import package.Defining a class "Count", and inside the class two method "countMultiples and main method" is declared.In the "countMultiples" method three integer parameter that are "low, high, and x".Inside this method a for loop is declared that uses the parameter value and use conditional statement with the % operator and check and return its values.Inside the main method three integer variable is declared that uses the scanner class to input the value and pass to the method and print its calculated value.  

Learn more:

brainly.com/question/16106262

Mối quan hệ giữa đối tượng và lớp
1. Lớp có trước, đối tượng có sau, đối tượng là thành phần của lớp
2. Lớp là tập hợp các đối tượng có cùng kiểu dữ liệu nhưng khác nhau về các phương thức
3. Đối tượng là thể hiện của lớp, một lớp có nhiều đối tượng cùng thành phần cấu trúc
4. Đối tượng đại diện cho lớp, mỗi lớp chỉ có một đối tượng

Answers

Answer:

please write in english i cannot understand

Explanation:

Write a program that reads in the size of the side of a square and then prints a hollow square of that size out of asterisks and
blanks. Your program should work for squares of all side sizes between 1 and 20. For example, if your program reads a size of 5, it
should print

Answers

Answer:

Explanation:

#include <iostream>

using std::cout;

using std::endl;  

using std::cin;  

int main()

{

int side, rowPosition, size;

cout << "Enter the square side: ";

cin >> side;

size = side;

while ( side > 0 ) {

rowPosition = size;

 while ( rowPosition > 0 ) {

if ( size == side || side == 1 || rowPosition == 1 ||  

rowPosition == size )

cout << '*';

else

cout << ' ';

--rowPosition;

}  

cout << '\n';

--side;

}

cout << endl;

return 0;

}

Please help urgently

Answers

Whats your question
Other Questions
define cell and atom What type of Literary Devices is this passage and provide an explanation" People moved slowly then. There was no hurry, for there was nowhere to go, nothing to buy and no money to buy it with, nothing to see outside the boundaries of Maycomb County." NEED THIS ASAP PLEASE Kelvin And Mimi studied the fruits. Kelvin concluded that there are more ovules in a mango flower than a papaya flower while Mimiargued that there are more ovules in a papaya flower than a mango flower.(a) who is correct?(b)Explain your answer in (a). Clayborn Company deposits all cash receipts on the day they are received and makes all cash payments by check. At the close of business on May 31, its Cash account shows a debit balance of $17,025. Clayborn's May bank statement shows $15,800 on deposit in the bank. Determine the adjusted cash balance using the following information: a british citizen who supported social reform in the victorian era would most likely call the government to Calculate the mass of water produced when 1.57g of butane reacts with excess oxygen for the equation BaCI2 + Na2SO4 > BaSO4 + 2NaCIA. reactants: 1 ;products: 1B. reactants: 1 ;products: 2C. reactants: 2 ;products: 1 D. reactants: 2 ;products: 2 Can someone help me with this problem? The body tries to return to a state of homeostasis (attempts to return to previous levels of functioning). As such, the body will keep fighting the perceived danger. Towards the end of the stage, levels of exhaustion, weariness, and anxiousness may occur as the body is becoming physically exhausted. Which stage of the General Adaptation Syndrome (GAS) is this Part 3Reading Comprehension Read the lecture below concerning geography. Then, The membrane potential that occurs when neurotransmitters bind to their receptors is called _______. whats the function for y=-4x+3 Which of the following was not part of the original cell theory, but was added later after we learned more about cellular structure?A. all cells have the same basic composition B. all cells come from pre-existing cellsC. all cells have a nucleus D. all cells have the same exact structures. What is the irony in the following quote?MACBETH: I drink to the general joy o' the whole table,And to our dear friend Banquo, whom we miss;Would he were here!1. Macbeth misses Banquo.2. Macbeth wishes Banquo was there because he is seeing his bloody ghost.3. Macbeth is scared about what the future brings for himself and his country.4. Macbeth is sad because he knows what he has done. BRAINlIEST FOR CORRECT ANSWER Which of the following parts of the brain is related to controlling water concentration and Osmosis?A. Basal GangliaB. ThalamusC. HypothalamusD. Pituitary Gland What is the domain and range of graph!!! 10 points!!! See if you can identify the verbs in the following sentences as active voice or passive voice. The verbs are in parenthesis.1. She (was awarded) the gold medal.2. I (thought) about it for a long while.3. The committee met for the last time on Friday.4. The school (was built) in 1970.5. I (built) a roller coaster out of Legos. What is the midpoint of the segment with endpoints(-4, -2) and (2, 6)? Pls help me with this