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
Paths describe the location of folders and files on your computer. If you have saved your work to c:\documents, then your work h
swat32
The answer is D and it can also be C
3 0
3 years ago
Read the citation example, and then use the drop-down menus to identify each part.
Lemur [1.5K]

Answer:

im notur e

Explanation:

5 0
3 years ago
Read 2 more answers
If you want the date in your document to update each time the document is opened, _____.
den301095 [7]
By clicking the update automatically<span> checkbox when inserting the date and/or time into a Word document... hope this helps!!!!</span>
8 0
3 years ago
Read 2 more answers
The _____ stage occurs when advancing IT leads to the development of a more advanced IT product making the old one obsolete and
Nikolay [14]

Answer

decline

Explanation:

The decline stage is the period where the relevance of a Technology making way for more advanced technology.

6 0
3 years ago
WHAT TYPES OF ACTIVITIES ARE PERFORMED BY HEALTH CARE SOFTWARES
Makovka662 [10]

Answer:

lectronic Health Record (EHR) Software. ...

Medical database software. ...

Medical research software. ...

Medical diagnosis software. ...

Medical imaging software. ...

E-prescribing software. ...

Telemedicine software. ...

Appointment scheduling (booking) software.

6 0
3 years ago
Other questions:
  • trhy356<br>yjetyi46ui y j4yhnpug 2utg[ 2[ 24[ou [o24t
    15·1 answer
  • If you enjoy working with livestock, the best cluster in which to research careers would be: A. Health Science. B. Agriculture,
    11·1 answer
  • 1024 Megabytes = ____________
    14·1 answer
  • dam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correct
    9·1 answer
  • Karl comes across confidential information. What should he do with it? A. Manipulate the information in his favor B. Sell the in
    12·1 answer
  • How do Computer Scientists use Binary Code?
    14·1 answer
  • Suppose we want to select between two prediction models M1 and M2. We have performed 10-fold cross validation on each. The error
    14·1 answer
  • List six features of the Microsoft ​
    10·1 answer
  • Select the correct answer.
    8·1 answer
  • Define a function FindLargestNum() with no parameters that reads integers from input until a negative integer is read. The funct
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!