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
Sidana [21]
3 years ago
14

Write a program that will ask the user to input a phrase (multiple word sentence), and an integer value. A static function will

be created that takes the sentence (string) and integer as input parameters and returns a single word (string) of that sentence. If the integer was the number three, then the word returned would be the third word in the sentence. If the integer given in zero or negative, simply return an empty string. (do not let it crash) If the integer given is higher than the number of words in the sentence, then just return the last word.

Computers and Technology
1 answer:
Andreyy893 years ago
4 0

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class Word

{

public static void main(String args[])

{

Scanner read=new Scanner(System.in);

char repeat='Y';

String phrase=null;

int index=0;

while(repeat=='Y')

{

System.out.println("enter a phrase :");

phrase=read.nextLine();

while(index<=0)

{

System.out.println("enter an index greater than 0");

index=Integer.parseInt(read.nextLine());

}

String s;

int spaces = phrase == null ? 0 : phrase.length() - phrase.replace(" ", "").length();

int numofwords=spaces+1;

if(index>numofwords)

{

index=numofwords;

}

System.out.println("word is: "+ getWord(phrase,index));

System.out.println("do you want to repeat (Y/N)");

repeat=read.nextLine().charAt(0);

index=0;

}

read.close();

}

private static String getWord(String phrase, int index) {

// TODO Auto-generated method stub

Scanner in =new Scanner(phrase);

String word=null;

int wordindex=0;

while(wordindex!=index)

{

word=in.next();

wordindex++;

}

in.close();

return word;

}

}

Check attachment screenshot

You might be interested in
A technician is configuring the Windows computers on a network to print to a printer that is directly connected to the network v
finlep [7]

Answer:

Network Printer

Explanation:

A network printer is a type of printer that is accessible by network connections, making it available for use by other computers connected to that network. The network can either come from the printer or from a local computer provided to create network for the printer. Most of them contains a network interface card that allow them connect directly to a local network from which computers can then access them. This is different from a local printer that is directly connect to the computer via USB cable.

Network printer is very advantageous in that multiple network computers can access the printer at thesame time.

7 0
3 years ago
2 4.1.2 Quiz: Information Systems and Business Planning
Delicious77 [7]

Answer:

Option D

Explanation:

Complete question

A management information system is typically used by _____.

A. all levels of employees

B. company executives

C. upper-level managers

D. middle-level managers

Solution

A management information system is typically used by middle-level managers

Option D is the correct answer

Management information system (MIS) helps the middle managers to control the work across the various teams of organization.

5 0
2 years ago
To bundle links together in order to improve bandwidth availability and redundancy, what protocol is used
Daniel [21]

Answer:

Link Aggregation Control Protocol

Explanation:

Link Aggregation Control Protocol can be used to assist in the formation of port channel bundles of physical links.

Link Aggregation Control Protocol is an IEEE standard defined in IEEE 802.3ad. LACP lets devices send Link Aggregation Control Protocol Data Units (LACPDUs) to each other to establish a link aggregation connection.

8 0
3 years ago
Which Traffic Source dimensions does Google Analytics automatically capture for each user who comes to your site?A. Source, Keyw
LenaWriter [7]

For each user who comes to your site the google analytics automatically capture the traffic source dimensions Source, Medium, Campaign name.

<u>Explanation:</u>

Source:

  • There cannot be any reference to a website without an origin source.
  • The source is basically the origin of your traffic such as a search engine (google) or a domain (ex: Twitter).

Medium:

  • Every referral to a website also has a medium along with the source.
  • examples are -:  unpaid search, "cost per click", referral, mail.

Campaign name:

  • The campaign Name is the name referring to the google ads campaign.
5 0
3 years ago
PLEASE HELP!!! Me turn this into a video &amp; add liana flores- raise the moon (instrumental) in the background for the music.
Marina CMI [18]

Answer:

Try going to your settings and allow output camera

Explanation:

5 0
1 year ago
Read 2 more answers
Other questions:
  • Is Apple a consumer or luxury brand? Give examples.
    10·1 answer
  • A slightly tapered thread is characteristic of a _______ tap.
    15·1 answer
  • The term "Big Data" is relative as it depends on the size of the using organization.
    14·1 answer
  • What organization is responsible for the registration of Internet domain names?
    14·1 answer
  • In the United States, everyone is guaranteed work true or false
    13·1 answer
  • The company database may be stored on a central database server and managed by a database adminstrator true or false
    12·1 answer
  • What is the output of the following program when the method is called with 4?
    11·1 answer
  • Which of the following is NOT a safe skill you can use to reduce your risk
    11·2 answers
  • What sorts of changes have you been observing in your society in your society in comparison in last 3 years​
    13·1 answer
  • Read the following scenario what type of business letter do you think is required in this situation?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!