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
Purpose In this lab activity, you will be introduced to the concept of enriching data with SPLUNK. This three-hour course is for
Vikki [24]

A person can enrich data in Splunk by

  • Preparing  to know data that is using Splunk to known the required fields in the data.
  • One need to think of this as if one is seeing pieces in a puzzle, then one can notice their shapes.
  • The next step is that one need to categorize data as a kind of a preamble before the act of aggregation and reporting.

<h3>What is Enriching Your Data?</h3>

Data enrichment is known to be a kind of an augmentation and it is seen as the act or the process of making better an existing information by the use of a  supplementing missing or any kind of incomplete data.

<h3> What is a Lookup?</h3>

Data Lookup is known to be the method used to make plenty any information based on rules.

Hence, A person can enrich data in Splunk by

  • Preparing  to know data that is using Splunk to known the required fields in the data.
  • One need to think of this as if one is seeing pieces in a puzzle, then one can notice their shapes.
  • The next step is that one need to categorize data as a kind of a preamble before the act of aggregation and reporting.

Learn more about SPLUNK from

brainly.com/question/26470051

#SPJ1

8 0
1 year ago
Initially, later, and finally are examples of what kind of words
Klio2033 [76]
Im pretty sure that the correct answer is Transition words.
3 0
3 years ago
Question 1
weeeeeb [17]

Answer:

-6.4

Explanation:

just divide -32 by 5 and you will get your answer of -6.4

7 0
2 years ago
My cell phone rear camera is dirty does anyone know how to clean it?
Vesna [10]
If you have glasses the liquid and cloth can be used to clean it. You spray the camera, then use the cloth to wipe it up. If you don't have them the dollar store should have some, or even places like Walmart and Maceys.
5 0
2 years ago
Read 2 more answers
Which of the following is an example of a syntax error?
Yuri [45]

Answer:

misspelling a programming language word

Explanation:

Syntax error is the type of error in programming, when the programmer insert some symbol that is not present in directories or libraries, the programmer not followed the rules of that particular programming language that is understandable to compiler.

For example in C++, it is necessary to insert the semicolon (;) after each statement. If the programmer not insert the semicolon after each statement, the program will show the syntax error.

If the programmer use integer instead of int to assign datatype to the variable in C++, it will also leads to the syntax error. Because in C++ library, Integer is defined with the help of "int".

4 0
2 years ago
Other questions:
  • Do transformers have life insurance or car insurance? If you chose life insurance, are they even alive?
    7·1 answer
  • The ____ file permission category in unix/linux systems typically entails all permissions and is designated by the letter u.
    7·1 answer
  • How do you delete a slide from your presentation after selecting it
    8·1 answer
  • What type of device does a computer turn to first when attempting to make contact with a host with a known IP address on another
    9·2 answers
  • n physics, a common useful equation for finding the position s of a body in linear motion at a given time t, based on its initia
    9·1 answer
  • What is the point of brainy when other people have to answer your questions but not the cumputer
    9·1 answer
  • My friend Leo wants to have an emergency plan for his final exams on University of Southern Algorithmville. He has N subjects to
    6·1 answer
  • Identify the correct characteristics of Python tuples. Check all that apply.
    9·1 answer
  • How exactly do you find the circumference by using C++ Programming? I really need a specific answer.
    14·1 answer
  • Which two peripherals are not required to browse the internet?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!