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]
3 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]3 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
(a) Convert to hexadecimal: 1457.1110. Round to two digits past the hexadecimal point.
zaharov [31]

Answer:

Following is attached solution to each part. I hope it will help you!

Explanation:

4 0
3 years ago
true or false manual handling of materials accounts for the primary source of energy in the workplace
Rus_ich [418]
True, hope this helps
6 0
3 years ago
Read 2 more answers
How many people are in Siver, on the game Valorant?
german

Answer:

probably like more than 20

5 0
3 years ago
How can a smartphone's gyroscope and accelerometer be used in product marketing? A. to locate the user's geographical position B
geniusboy [140]

Answer:

Option (C) is the correct answer of this question.

Explanation:

The smartphone's gyroscope and accelerometer  that can be used in the product of  marketing the potentials customers can tilt and turn over the smartphones in the 360 degree views of products.Sensors were around long before the smartphone. Yet they have not only made their way to the modern age, but are also becoming wider and wider.

An accelerometer is capable of measuring both momentum orientation and pharmacological acceleration.The gyroscope helps to sense more subtle changes in alignment.

Other option sare incorrect because they are not related to the given scenario.

8 0
3 years ago
IF YOU COULD CREATE A SOCIAL NETWORK:, what would it be like? What would make it so special about the others? (If you want you c
frosja888 [35]

It would be like instagram

3 0
3 years ago
Other questions:
  • Jason wants to open a program with the command prompt window. Which command should he type in the Run dialog box to open the com
    10·1 answer
  • If you use the ___ template, as opposed to a formatted theme, you must make all design decisions?
    15·1 answer
  • What is the maximum transmission speed for bluetooth v3 and v4 devices?
    12·1 answer
  • You recently discovered that Marketing1 can connect to Admin1, and Admin1 can connect to Marketing1, but neither of these comput
    11·1 answer
  • When performing a basic search with Bing, you first type in your search expression and then click a button to begin the search;
    13·1 answer
  • Which are examples of non-linear presentations? Choose all that apply.
    11·1 answer
  • program 2. write a VB.NET program to solve the linear equation of the form Ax+B=C, i.e x=(C=B)/A (Eg:2x+3=7, where B and C are c
    15·1 answer
  • Edhesive in JAVA Write a method that takes a String parameter. If the String has a double letter (i.e. contains the same letter
    13·1 answer
  • Select the correct answer.
    5·1 answer
  • Which of the following can be termed ‘application software’?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!