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
lesya [120]
3 years ago
10

Make a program that prints each line of its input that mentions fred. (It shouldn’t do anything for other lines of input.) Does

it match if your input string is Fred, frederick, or Alfred? Make a small text file with a few lines mentioning "fred flintstone" and his friends, then use that file as input to this program and the ones later in this section.
Computers and Technology
1 answer:
Vitek1552 [10]3 years ago
8 0

Answer:

See Explaination

Explanation:

This assume that input is a file and is given on command line. Please note this will ot print lines with frederick as thats what I feel question is asking for

#!/usr/bin/perl -w

open(FILE, $ARGV[0]) or die("Could not open the file $ARGV[0]");

while ($line = <FILE>){

if($line=~/\s+fred\s+/)

{

print $line;

}

}

close(FILE);

You might be interested in
A(n) ________ operator, such as the greater than or less than symbol, can be used in a query criterion to limits the results pro
Tcecarenko [31]

Answer:

A _comparison_ operator, such as the greater than or less than symbol, can be used in a query criterion to limits the results produced by the query

5 0
3 years ago
Read 2 more answers
You should process the tokens by taking the first letter of every fifth word,starting with the first word in the file. Convert t
zhenek [66]

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);

}

}

}

5 0
3 years ago
What happens to runt frames received by a cisco ethernet switch?
Nikolay [14]

Answer:

thank you sa point labyu stay safe

5 0
2 years ago
What names of websites of presentation or visualization <br>​
Fittoniya [83]

Explanation:

Google Slides. Google has made a conscious effort to emulate many of MS Office's tools, and Slides is their alternative to PowerPoint. ...

DesignBold. ...

PowToon. ...

Slides. ...

ClearSlide. ...

Moovly. ...

Prezi. ...

KnowledgeVision.

5 0
3 years ago
Which of the following is the best example of market censorship
Papessa [141]
To bleep it out! hopefully this helped
4 0
3 years ago
Read 2 more answers
Other questions:
  • Before starting a spreadsheet, it is smarter to plan ahead and think through the design. true or false
    13·1 answer
  • How useful do you find the creation of folders in your computer?
    8·2 answers
  • Which is a good guideline to follow when choosing a background for your slides?. . A. Use a different background for each slide.
    8·1 answer
  • Budgets help you to do all of the following expect
    15·2 answers
  • What is the name of the file manager in Microsoft Windows. The file manager used in Microsoft Windows is?
    12·2 answers
  • How do u use this app?
    15·2 answers
  • What is output?
    13·1 answer
  • Research and build a chroot jail that isolates ssh users who belong to the restrictssh group. (You will also need to create the
    9·1 answer
  • The first cell phones in widespread use were . Smartphone technological advancements added services. Answer the following questi
    12·2 answers
  • Complete the sentence.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!