answer.
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
Write an expression that will cause the following code to print "I am a teenager" if the value of userAge is less than 20. Zyboo
VikaD [51]

Answer:

Replace

if userAge > 20

with

userAge > 19

Explanation:

if userAge > 20  checks if age is 21, 22, 23, 24........

The else condition which prints "I am a teenager" checks if age is 20, 19, 18....

Notice that 20 is inclusive of the else condition; this shouldn't be because for userAge to be less than 20, 20 isn't inclusive

To solve this,

Replace if userAge > 20 with userAge > 19

So that, the else

The else condition which prints "I am a teenager" checks if age is 19, 18, 17, 16....

6 0
2 years ago
A(n) ______of the audio or video clip makes the content easily accessible to people with hearing disabilities.
defon

subtitles

hope that helped you

7 0
2 years ago
Read 2 more answers
An encryption system works by shifting the binary value for a letter one place to the left. "A" then becomes: 1 1 0 0 0 0 1 0 Th
Vika [28.1K]

Answer:

The hexadecimal equivalent of the encrypted A is C2

Explanation:

Given

Encrypted binary digit of A = 11000010

Required

Hexadecimal equivalent of the encrypted binary digit.

We start by grouping 11000010 in 4 bits

This is as follows;

1100 0010

The we write down the hexadecimal equivalent of each groupings

1100 is equivalent to 12 in hexadecimal

So, 1100 = 12 = C

0010 is represented by 2 in hexadecimal

So, 0010 = 2

Writing this result together; this gives

1100 0010 = C2

Going through the conversion process;

A is first converted to binary digits by shifting a point to the left

A => 11000010

11000010 is then converted to hexadecimal

11000010 = C2

Conclusively, the hexadecimal equivalent of the encrypted A is C2

8 0
2 years ago
Consider the eight bit signed binary number 1110 0101. Convert it to signed decimal from assuming the signed binary number is re
lapo4ka [179]

Answer:

-26

Explanation:

The given binary number is 1110 0101. Also given that the signed binary number is represented using one's compliment.

We begin by computing the 1s complement representation of 1110 0101 by inverting the bits: 00011010

Converting 00011010 to decimal, it corresponds to 26.

So the 1s complement of the original number is 26. This means that the original number was -26.

7 0
2 years ago
Your company just bought a new subsidiary based in Des Moines, Iowa. Although your local operation already uses IPv6 for local n
AlexFokin [52]

Answer:

Answer explained below

Explanation:

Following are the arguments that can be used to persuade our colleagues in Des Moines to switch there network to IPv6 or to enable dual use of IPv6 and IPv4 :

  • IPv6 provides an increased capacity of address space as resources are efficiently allocated to provide coverage to additional web addresses.
  • IPv6 provides efficient routing by conveniently aggregating the prefixes that have been assigned to IP networks.
  • IPv6 conserves bandwidth by enabling large data packets. it uses less bandwidth than IPv4 for the same data.
  • IPv6 is more secure than IPv4 due to multiple security layers built in the firewall. It also provides authentication layers and integrity of data.
  • IPv6 supports multicast rather than broadcast.
  • IPv6 has more efficient packet processing and error detection through checksum as compared to IPv4.
  • Address and network configuration is fully simplified and automatic in IPv6 but the same is not true for IPv4.
  • IPv4 supports 32 bit IP address whereas IPv6 supports 128 bit. Therefore more number of IP addresses availability makes IPv6 future oriented.
6 0
2 years ago
Other questions:
  • In a situation where handicapped person can only input data into the computer using a stylus or light pen, which keyboard config
    7·2 answers
  • Currently, there are two major techniques used to develop programs and their procedures. name and describe them. html editor key
    11·1 answer
  • In what year were graphical user interfaces (GUIs) pioneered? 1969 1974 1991 2001
    12·2 answers
  • Which set of variables will make code easier to understand?
    14·1 answer
  • Zoey has brought her computer in for servicing. When she dropped off her computer, she mentioned that her computer will sometime
    15·2 answers
  • Nicole wants to create a database to collect information about videos in her video rental store. She would like to use the datab
    9·1 answer
  • 1. Show that the three security services-confidentiality, integrity, and availabilty- are sufficient to deal with the threats of
    10·1 answer
  • An Internet user has a need to send private data to another user. Which of the following provides the most security when transmi
    14·2 answers
  • Write a program that lets a user enter N and that outputs N! (N factorial, meaning N*(N-1)*(N-2)*..\.\*2*1). Hint: Initialize a
    5·1 answer
  • Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!