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
Ainat [17]
2 years ago
6

Write code which takes a sentence as an input from the user and then prints the length of the first word in that sentence.

Computers and Technology
1 answer:
Afina-wow [57]2 years ago
7 0

import java.util.Scanner;

public class U2_L3_Activity_Four {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter a sentence.");

       String sent = scan.nextLine();

       int count = 0;

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

           char c = sent.charAt(i);

           if (c != ' '){

               count++;

       }

           else{

               break;

           }

       

   }

       System.out.println("The first word is " + count +" letters long");

   

   }

}

We check to see when the first space occurs in our string and we add one to our count variable for every letter before that. I hope this helps!

You might be interested in
dash is a set of communication standard using for transferring file information between computers in a network​
8090 [49]

Answer:

protocol

Explanation:

hope this helps.

4 0
2 years ago
During the boot process, the computer performs a quick self diagnostic then loads the operating system into memory.... IS THIS T
zlopas [31]
<span>The answer is False.  During the boot process, the computer will perform a self-diagnostic, also known as a POST and load necessary drivers and programs that help the computer and devices communicate.</span>
7 0
2 years ago
A search engine displays a list of webpage names that contain the search text. what is the term for that list?
Minchanka [31]
<span>A search engine displays a list of webpage names that contain the search text. The term for that list is hit.
Basically, what this term refers to is the number of visits, or a number of downloads that happened on that particular webpage. It is a good tool to measure web traffic, or how much that page is visited.
</span>
6 0
3 years ago
What is web browser <br>​
xeze [42]
An application used to access and view websites
7 0
3 years ago
Read 2 more answers
A set of object that share a common structure and common behavior in database is called ​
Tcecarenko [31]
An Object Class. Hopefully this answer is right.
3 0
3 years ago
Other questions:
  • An administrator needs to set up an authentication server for users connecting to a network through a VPN. What kind of server c
    10·1 answer
  • Open a command prompt on PC1. Issue the command to display the IPv6 settings. Based on the output, would you expect PC1 to be ab
    7·1 answer
  • Describe what is meant by the following:
    14·1 answer
  • Page UND
    8·1 answer
  • To drive defensively means taking proactive measures to avoid accident situations regardless of their potential causes.
    6·2 answers
  • HELP PLEASE
    7·1 answer
  • What is added to brining liquid to add flavour​
    6·1 answer
  • Most scheduling algorithms maintain a run queue, which lists processes eligible to run on a processor. On multicore systems, the
    10·1 answer
  • Which of these is a possible disadvantage of working with a team?
    6·1 answer
  • You can open a movie maker project file any time in a media player. (1 point) true false
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!