Write code which takes a sentence as an input from the user and then prints the length of the first word in that sentence
1 answer
Question:
Write code which takes a sentence as an input from the user and then prints the length of the first word in that sentence
Answers
Answer:import java.util.*; class StringProgram { public static void main(String s[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter a Sentence: "); String str= sc. nextInt(); // trim the white spaces at the beginning and at the end. str = str.trim(); int c=0; int i=0; while(str.charAt(i++)!=' ') ++c; System.out.println("Length of the first word in the sentence is: "+c); } } Explanation:
Similar Solved Questions
1 answer
Can someone answer these for me please I’m terrible at sex linked traits
can someone answer these for me please I’m terrible at sex linked traits...
1 answer
If a Native American lived on their allotted land for 25 years, what would he/she have to do to get their U.S. citizenship? A) pay a fee B) file a petition C) join the military D) become "civilized"
If a Native American lived on their
allotted land for 25 years, what would
he/she have to do to get their U.S.
citizenship?
A) pay a fee
B) file a petition
C) join the military
D) become "civilized"...
1 answer
Which expressions are completely factored? Select each correct answer. pick more then 1 18x4−12x2=6x(3x3−2x) 12x5+8x3=2x3(6x2+4) 24x6−18x5=6x5(4x−3) 20x3+12x2=4x2(5x+3) Which statements are true? Select each correct answer. pick more then 1 8x3−6x=2x3(4−3x3) 30x4−12x3=6x3(5x−2) 100x3+5=5x3(20x+1) 4x2+10x=2x(2x+5)
Which expressions are completely factored? Select each correct answer. pick more then 1
18x4−12x2=6x(3x3−2x)
12x5+8x3=2x3(6x2+4)
24x6−18x5=6x5(4x−3)
20x3+12x2=4x2(5x+3)
Which statements are true?
Select each correct answer. pick more then 1
8x3−6x=2x3(4−3x3)
30x4−12x3=6x3(5x−2...
2 answers
In American society, which of these is an example of a want? food shoes television rent
In American society, which of these is an example of a want?
food
shoes
television
rent...
2 answers
3. The Moghul Emperor attacked the kingdom of______4.---- was a capable Vazir of Nizamshah,
3. The Moghul Emperor attacked the kingdom of______4.---- was a capable Vazir of Nizamshah,...
1 answer
In Firm A, each division is a self-contained, largely autonomous entity with full responsibility for its own value creation activities. What type of structure does Firm A employ
In Firm A, each division is a self-contained, largely autonomous entity with full responsibility for its own value creation activities. What type of structure does Firm A employ...
1 answer
Your friend currently works as an accountant at a public accounting firm in the small town of Beaver Falls, Pennsylvania. He is offered a job in San Francisco for $60,000. Your friend calls you and tells you that he is excited about the new job offer, which gives him a raise from his current salary of $50,000. Based on your knowledge of economics, you think that
Your friend currently works as an accountant at a public accounting firm in the small town of Beaver Falls, Pennsylvania. He is offered a job in San Francisco for $60,000. Your friend calls you and tells you that he is excited about the new job offer, which gives him a raise from his current salary ...
2 answers
The quotient of x and 3 decreased by the sum of x and y
the quotient of x and 3 decreased by the sum of x and y...
2 answers
A scientist analyzes the light from a distant galaxy and finds that it is shifted to the longer wavelength of the electromagnetic spectrum. What does this data help to study? 1) the color of the galaxy 2) the distance of the galaxy from Earth 3) the existence of life on any planet in the galaxy 4) the study of the amount of light scattered by dust in space
A scientist analyzes the light from a distant galaxy and finds that it is shifted to the longer wavelength of the electromagnetic spectrum. What does this data help to study?
1) the color of the galaxy
2) the distance of the galaxy from Earth
3) the existence of life on any planet in the galaxy
4) t...
2 answers
X and Y are two stations which are 320 miles apart. A train starts at a certain time from X and travels towards Y at 70 mph. After 2 hours, another train starts from Y and travels towards X at 20 mph. At what time do they meet?
X and Y are two stations which are 320 miles apart. A train starts at a certain time from X and travels towards Y at 70 mph. After 2 hours, another train starts from Y and travels towards X at 20 mph. At what time do they meet?...
1 answer
How was the American experiment with a government by the people different from the typical government of a country in the 1700s?
How was the American experiment with a government by the people different from the typical government of a country in the 1700s?...
1 answer
If I have a 90 in math and i make a 66 on a test worth 10 percent of my grade how much did my grade drop
if I have a 90 in math and i make a 66 on a test worth 10 percent of my grade how much did my grade drop...
1 answer
Which inference is supported by the passage? {Greeks}
Which inference is supported by the passage?
{Greeks}...
2 answers
Select all that apply to the oxford english dictionary (o. e. d.
Select all that apply to the oxford english dictionary (o.
e.
d....