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
Dmitrij [34]
3 years ago
11

Imagine the user types in a complete sentence, but we want to read only the first word and place it in the String variable word.

What are the statements that will declare the Scanner object and read the value of word
Computers and Technology
1 answer:
Vladimir [108]3 years ago
8 0

Answer:

import java.util.Scanner;

public class FirstWord {

   public static void main(String[] args) {

       //NOW YOU WANT TO COLLECT INPUTS FROM THE STUDENT OR USER

       //IMPORT THE SCANNER CLASS FIRST  outside your class

       // THEN YOU CREATE AN OBJECT OF THE SCANNER CLASS

       Scanner input = new Scanner(System.in);

       

       //CREATE A VARIABLE TO HOLD THE USER INPUT

       String text = input.nextLine();

       

       //The variable holder will be used to store characters from the for loop

       String holder="";

       

       //Create a for loop that loops through the user's input

       for(int i=0; i<text.length(); i++){

           //As the loop increases, we get the character in the user's input and store them one by one in the variable holder

           holder+=text.charAt(i);

           if(text.charAt(i)==' '){

               //If the loop encounters a space, it means a complete word has been gotten from the user's input

               //Then the break below Breaks the loop, and the loop stops running

               break;

           }

       }

       System.out.println(holder);

}

Explanation:

text.length() returns the length of the sequence of characters present in length

text.charAt(a number) Returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array indexing.

Create a for loop

How does a for loop work?

It collects a starting point, an end point and an increment respectively....all these are passed in as arguments into the for loop

For example, the code above starts from 0, calculates the number of characters in the user's input and sets it as the end point, the loop runs from zero to the length of the text of the user...

Note: i++ in the loop is the increment, it means the loop increases by 1

You might be interested in
Question :
BlackZzzverrR [31]

Answer:

D

Explanation:

Search engine optimization (SEO)

4 0
3 years ago
Can someone please help me with this pleaseeeee
vladimir1956 [14]

Answer:

The answer of this question is given below into explanation section

Explanation:

answer (a)

I visited the carrerbuilder dot com and search for data entry job. The link of the posting is given below

https://www.careerbuilder.com/jobs?utf8=%E2%9C%93&keywords=data+entry&location=

answer(B)-Requirements of the the job

  • Previous office experience (data entry experience a plus)
  • Proficient with a computer and computer software (Excel knowledge required)
  • Excellent verbal and written communication skills
  • The ability to multi-task and work in a team-oriented environment
  • High School Diploma / G.E.D.
  • Ability to meet background check and drug screening requirements

answer(C)-Tasks of the job

  • Open, sort, and scan documents
  • Track all incoming supplies and samples
  • Data entry of samples that come in
  • Assist with documentation and maintaining of data
  • Prepare and label information for processing
  • Review and correct any data entry error or missing information

answer (d)

I have 3 years of experience in organization administration where I managed the organization data, generated reports and communicated verbally and written within the organization efficiently.

6 0
3 years ago
Why do astronomers prefer to use the reflecting telescope rather than the refracting telescope to view distant objects in space?
sdas [7]
C is the right answer
7 0
3 years ago
Read 2 more answers
In which of the following situations is having a good credit score important?
Triss [41]
<span>The correct answer is to be able to loan from banks. Having a good credit score, impacts one's approval for bank loans. It will enable a person to have a higher chance of getting his or her loan, approved by the banks, than those who have low credit scores. </span>
8 0
3 years ago
In 2007, __________ Floridians died in alcohol-related collisions. A. 501B. 1,051C. 5,015D. 10,839
wel

1000 people died of an alcohol addiction

4 0
3 years ago
Other questions:
  • Computers are often referred to as _____.
    15·1 answer
  • To edit the color of the text in presentation software, choose the Font color command Text Color in the ________ ribbon toolbar.
    15·2 answers
  • Which of the following choices is not a viewing option?
    10·1 answer
  • Case 2-2 Jack has a computer at home that he uses to access the Internet, store and edit personal photos, and create and edit do
    9·1 answer
  • Write a program to generate following series in qbasics 100,81,64,....1​
    13·1 answer
  • it is used to hold screws, jumpers, fasteners, and other small parts and prevent them from getting mixed together​
    15·2 answers
  • Which type of protocol allows for a secure data transmission using encryption methods?
    7·1 answer
  • Which of the following is NOT a possible combination of values of the variables in this program when it finishes running?
    6·2 answers
  • Immigrants are allowed to enter the country to work when they have a(n)
    10·1 answer
  • How do you get lugia in pokemon alpha saphire
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!