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
On the food inventory worksheet, enter a function in cell G1 that counts the number of Food Items. What formula would i use!? Th
Nataly [62]

COUNT function

COUNT function determines how many cells in a range contain a number. We use this function to get the number of entries in a number field in an array of numbers. The formula one can use is G1:[…..]: = COUNT(G1:[…..])






3 0
3 years ago
In the spreadsheet example shown in chapter 5 ____ run from top bottom and are designated by a letter?
Basile [38]

The answer is D. Columns. Columns are vertical, ranges lie within the columns, rows are horizontal, and the table is the actual spreadsheet I believe.

6 0
3 years ago
Read 2 more answers
Software applications called _____ provide the means to record information that passes through a computer or router that is hand
Bezzdna [24]

Answer:

sniffer programs

Explanation:

Software applications called <u>sniffer programs</u>  provide the means to record information that passes through a computer or router that is handling Internet traffic.

3 0
3 years ago
Bunco is a dice throwing game that requires no decisions to be made or skill on the part of the player just luck. In the simples
anygoal [31]
Abcdefghijklmnopqrstuvwxyz now I know my abcs, next time won’t you sing with me :)
8 0
2 years ago
The total number of possible keys for des is _________, which a modern computer system can break in a reasonable amount of time.
FinnZ [79.3K]
The answer is two. Most people think it's one but it's 2
3 0
3 years ago
Other questions:
  • In a transaction-processing system (TPS), if the TPS database can be queried and updated while the transaction is taking place,
    12·1 answer
  • • Write a program to find the maximum, minimum, and average score of players. The input to the program is a file containing play
    9·1 answer
  • Which of these browsers was the first widely adopted?
    12·1 answer
  • What are the meaning master files<br>​
    8·1 answer
  • How should you set the OHMS ADJust control on a multitester of analog VOM, for resistance measurements?
    12·1 answer
  • Steps in the systems development life cycle​
    15·2 answers
  • Lazarus Consulting is a large computer consulting company in New York. Pete Lazarus, theà CEOà and founder, is well known for hi
    8·1 answer
  • Where is information stored in the computer?​
    9·1 answer
  • How does the use of blocking affect the external sorting algorithm, and how does it change the cost formula
    5·1 answer
  • What is the value of six sigma ? How dose it relate to agile management
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!