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
nataly862011 [7]
3 years ago
12

You should process the tokens by taking the first letter of every fifth word,starting with the first word in the file. Convert t

hese letters to uppercase andappend them to a StringBuilder object to form a word which will be printedto the console to display the secret message.
Computers and Technology
1 answer:
zhenek [66]3 years ago
5 0

Answer:

See explaination

Explanation:

import java.io.File;

import java.io.IOException;

import java.util.Scanner;

import java.util.StringTokenizer;

public class SecretMessage {

public static void main(String[] args)throws IOException

{

File file = new File("secret.txt");

StringBuilder stringBuilder = new StringBuilder();

String str; char ch; int numberOfTokens = 1; // Changed the count to 1 as we already consider first workd as 1

if(file.exists())

{

Scanner inFile = new Scanner(file);

StringTokenizer line = new StringTokenizer(inFile.nextLine()); // Since the secret.txt file has only one line we dont need to loop through the file

ch = line.nextToken().toUpperCase().charAt(0); // Storing the first character of first word to string builder as mentioned in problem

stringBuilder = stringBuilder.append(ch);

while(line.hasMoreTokens()) { // Looping through each token of line read using Scanner.

str= line.nextToken();

numberOfTokens += 1; // Incrementing the numberOfTokens by one.

if(numberOfTokens == 5) { // Checking if it is the fifth word

ch = str.toUpperCase().charAt(0);

stringBuilder = stringBuilder.append(ch);

numberOfTokens =0;

}

}

System.out.println("----Secret Message----"+ stringBuilder);

}

}

}

You might be interested in
What are some common options to sort a mail merge recipient list?
Anni [7]

Answer:

by city

by ZIP code

by last name

4 0
2 years ago
Read 2 more answers
Is there anybody who knows eris quirk but me- i feel lonely rn ;-;
Nutka1998 [239]

Answer:i do Eri's Quirk allows her to rewind an individual's body to a previous state. She has shown the ability to rewind someone's body to a point before they existed, which she accidentally did to her father.

3 0
3 years ago
Read 2 more answers
Andrew is graduating from high school and is very interested in computers and programming. Based on the programming language mar
Anika [276]

Answer:

B. Identify the most popular languages to determine the highest job demand.

Explanation:

You are not here to gain just experience or identify the language that is most compatible with various other languages for various skills. And these programming languages are standards, and hence you are not required to check them for turning completeness tests to meet various programming criteria. The correct option for you will be to identify the most popular languages to determine the highest job demand. And hence, B. is the right option for this question.

5 0
3 years ago
Many people in the United States will say that they have rights, however, the majority of those people do not know what those ri
8090 [49]

Answer:

I think this answer would be...

Three of the rights guaranteed by the bill of rights would be freedom of speech, freedom of religion, and the right to bear arms. Freedom of speech lets me say what I need to or what but there are consequences to what I say. Freedom of religion allows me to practice any religion in the united states without it being illegal. The right to bear arms allows me to own a gun to hunt or protect myself when needed with a license or orange card.

3 0
2 years ago
Read 2 more answers
An artificial satellite in which people can live and work for long periods is called a
morpeh [17]
A space station is an artificial satellite in which people can live and work for a long period of time. Space station is placed on the space for the astronaut in researching things on the space and universe.
8 0
3 years ago
Read 2 more answers
Other questions:
  • 5. Why would you want to wear white or light colors on a summer day?
    5·1 answer
  • A. True
    8·2 answers
  • Ken is moving to a new city and considering whether he should rent or buy an apartment. what factors should he consider in his d
    5·1 answer
  • How does the purchase of office equipment on account affect the accounting equation?
    11·2 answers
  • I’m trying to get answers from Brainly and it’s not showing up. I’ve been refreshing the browser, but it’s the same. I’ve never
    10·2 answers
  • What was the basic invention that has evolved into the modern automobile?
    13·1 answer
  • An application with which you can perform calculations on numbers and work with other data
    8·1 answer
  • What power brake uses vacuum from the engine to aid in brake application?
    6·2 answers
  • What are the different types of application architecture
    5·1 answer
  • Explain drawing and painting package.​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!