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 band from the 1970s has reunited. They want to revive their careers, but they do not have the funding they once did. An intern
AnnyKZ [126]

A band from the 1970s has reunited. They want to revive their careers, but they do not have the funding they once did. An international tour is not financially possible. The band needs to build renewed interest in their music and make a profit.

Which of the following would be the best decision for this band? \\

-----------------------------------------------------------------------------------------------------

Correct Answer:

<u><em>B) Plan a one-night reunion concert that will be broadcast live, online, and on cable, then sell recordings of the event.</em></u>

<u><em></em></u>

<em>Explanation:</em>

I got the answer correct on EDG2020.

<em />

4 0
3 years ago
Which type of evidence should victims collect to help officials catch cyber bullies
iren [92.7K]

Answer:

How you get cyberbullied just look away from the screen -Tyler The Creator

Explanation:

3 0
4 years ago
Read 2 more answers
The activity spikes during black Friday sales in the holiday season but significant stress on a major retailers website what fea
Elza [17]

Answer:

My Nav is the right answer.

Explanation:

Net asset value (NAV) describes a fund's per part exchange value. NAV is calculated by separating the complete value of all the money and securities in a fund's responsibility, minus any mortgages, by the number of exceptional shares. The NAV estimation is necessary because it shows us how much one portion of the fund is worth.

4 0
3 years ago
Who Has any idea How to code?
kkurt [141]
A bit I guess. I can only do C# though
8 0
3 years ago
Read 2 more answers
Unit testing: Select one:
ser-zykov [4K]

Answer:

e. tests each program separately.

Explanation:

Unit testing -

It is one of the software testing where the individual units are tested , is referred to as unit testing.

The focus of this step is to scan each and every unit separately and thoroughly so as to avoid any type of damage or malfunctioning .

Hence, from the question, the correct statement for unit testing is e. tests each program separately.

5 0
3 years ago
Other questions:
  • Question 1 : Which statement is true about interlaced images? This task contains the radio buttons and checkboxes for options. T
    8·1 answer
  • I need help to find out what is wrong with this program and my variable, "exponent" comes out as 0 in the output instead of the
    14·1 answer
  • Cloud computing service providers manage different computing resources based on the services they offer. Which resources do IaaS
    10·1 answer
  • A technician has verified that a video card to be added to a desktop machine will fit and so will a new sound card. What should
    15·1 answer
  • An employee clicks on a link in an email from what looks like a fellow employee and is taken to a fraudulent web site which asks
    6·2 answers
  • write a function that given an integer Y and 3 non-empty string A,B,W, denotingthe year of vacations, the beginning month, the e
    5·1 answer
  • What Is entered into the system as input?
    13·1 answer
  • Complete the sentence.<br> In your program, you can open
    5·1 answer
  • The conversion rate is the percentage of what? A. Customers who received cold calls B. Sales leads who reached the interest stag
    13·1 answer
  • (Synchronized threads) Write a program that launches 1000 threads. Each thread adds a random integer (ranging from 1 to 3, inclu
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!