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
. Generate 106 message bits (random binary values (bool/int) ). 2. Generate the corresponding code bits for r = 3, 5. This means
N76 [4]

Answer:

While loops are typically used when you don’t know how many times the loop needs to repeat. The body of the loop will repeat while the condition is true. The logical expression will be evaluated just before the body of the loop is repeated.

Let’s say that we want to find the square root of a number. For some square roots, you’re never going to be exact. Let’s say that we want to find a square root that, when multiplied by itself, is within 0.01 of the square we want. How do we do it? There’s a really old process that we can apply here.

Start by guessing 2.

Compute the guess squared.

Is the guess squared close to the target number? If it’s within 0.01, we’re done. We’ll take the absolute value of the difference, in case we overshoot. (In Python, abs is the absolute value function.)

If it’s not close enough, we divide the target number by our guess, then average that value with our guess.

That’s our new guess. Square it, and go back to Step #3.

Explanation:

7 0
3 years ago
What a suitable variable name to store the number of years old a person is
navik [9.2K]

age is a suitable variable name. It's descriptive and concise. Make sure it's lowercase.

8 0
3 years ago
Computer is a versative Idiot, explain with respect to teaching and learning<br>​
Verizon [17]

Answer:

Computer is a versative Idiot, explain with respect to teaching and learning

Explanation:

Primary Logo

Introduction to Computer

Subject: Computer

Home Grade 9 Computer Introduction To Computer Introduction To Computer

Search for notes, Q&As, Videos, etc.

Syllabus

Introduction to Computer

Introduction to Computer

History of Computer

Applications of Computer

Electro Mechanical Computers

Generation of Computer

Computer Systems

Types of computer

Computer Hardware

Computer Software

Number System

Operating System

Information System and Social Impact of Computer

Information Technology Policy

Concept of E-Governance

Webpage Designing

Algorithm and Flowchart

Program and Programming Languages

QBASIC Programming

Overview

Computers are the machines that can perform tasks or calculations according to set of instructions or programs. This note introduces you with the computer.

Note

Things to remember

Videos

Exercise

Quiz

Introduction to Computer

Computers are the machines that can perform tasks or calculations according to set of instructions or programs. The term computer is derived from the word compute which means to calculate. Computer is an electronic device that can perform arithmetic and logical calculations faster. The first fully electronic computers, introduced in 1940s, were huge machines that required teams of people to operate. Compared to those early machines, today's computers are not only thousand times faster, they can fit on your desk, lap and even pocket. You must appreciate the impact of computer in our day-to-day life. The computer has been useful in reservation of tickets in Airlines and Railways, payment of telephone and electricity bills, deposits etc.

Advantages of computer

Computers are very fast due to which thousands of job can be performed within a short period of time.

Complex mathematical problems and logical operations can be solved by using this computer.

As computer is a versatile device, multiple task like communication, graphics, documentation can be done.

A huge amount of data can be stored and retrieved as it has high storage capacity.

Disadvantages of computer

Computers are machine hence, they have no brain so they work according to the program instructions set inside it.

It is an electronic device and it uses electrical sources to work, so it is very risky to store data and information on the computer independently because some electrical and electronic damages may damage the data. So we have to make regular backup of the data.

Since computers are very expensive device, it becomes beyond the capacity of general user. But now a day its price is going down than past.

Computers require dustless and temperature maintained environment for best performance

6 0
2 years ago
What
AveGali [126]
Answer: Computers and cellular devices
Reason: Everyone every day watched entertainment with commercials of the internet all day on these technologies and proven by 92 percent. Make this brainly answer for everyone else that needs this. Hope this helps:)
8 0
2 years ago
Match each feature of the E publishing as an advantage a disadvantage a threat or an opportunity
natta225 [31]

Answer:

E-publishing is also known as digital publishing or online publishing.It means to publish the content in electronic form.It is growing rapidly.It consist digital publication of e-books,digital magazines that can be read on a screen.

<u>Explanation:</u>E-publishing is very convenient.We do not have to keep  large number of books on the shelves.E-books are best during travelling because we need not to carry heavy luggage of books.E-books are cheaper than paperbacks.

E-publishing can allow the authors  to reach large number of readers.Electronic contents are very well updated.Electronic books are environment friendly.It saves wastage of papers and hence cutting of trees.

Besides above advantages there are some disadvantages of E-publishing:

There are more responsibilities in E-publishing.Chances of copyright infringement can be there.

Profits are very low in case of e-publishing.It is not easy to earn money through this method.

Quality of printed books is much better than e-books.

So we can say that e-publishing has it's own advantages and disadvantages.

3 0
3 years ago
Other questions:
  • Edward has started up a new company with his friend, Matthew. Currently, he has only two people working with him. Which type of
    8·1 answer
  • What is 1-7? Plz help!!!
    15·1 answer
  • What will happen if Sam goes to the View menu, clicks Toolbars, and then clicks Picture?
    12·2 answers
  • FTP requires confirmation that a file was successfully transmitted to a client, but it has no built-in mechanism to track this i
    7·2 answers
  • Which screen should be open to customize or personalize a desktop background?
    15·2 answers
  • How do you change your grade level
    10·1 answer
  • You are implementing a RAID storage system and have found a system with eight 100 GB drives. How much storage space will you hav
    5·1 answer
  • Q.No.3 b. (Marks 3)
    5·1 answer
  • "En la opción
    10·1 answer
  • Please help I’ll give 10 points
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!