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
Vera_Pavlovna [14]
3 years ago
14

Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of strings

and two int variables, count and longest, write the code necessary to examine all the strings in the input source and determine how long the longest string (or strings are). that value should be assigned to longest; the number of strings that are of that length should be assigned to count.
Computers and Technology
2 answers:
Makovka662 [10]3 years ago
7 0

The code that examines all the strings in the input source and determines how long the longest string (or strings are) is the following:

total = 0; % initial value is zero, in every while loop it will be incremented

while(input.hasNextInt()){

total += input.nextInt( );

}

BlackZzzverrR [31]3 years ago
5 0

Answer:

int count = 0;  //int variables

int longest =0;  // int variables

Scanner input = new Scanner(System.in); // given input is reference variable

String str= new String();  // creating object of sting class

while (input.hasNext()) // taking the input by using scanner reference

{

str= input.next();  // taking input in string

if (str.length() == longest) // checking condition

++count;  // increment the count

else

if (Str.length() > longest) // if string is greater then longest

{

longest = str.length(); // calculating length

count = 1;  // assign count to 1

}

}

Explanation:

Following are the description of the code :

  • Declared a two variable count and longest of  int type.
  • Create a object of String class i.e 'str".
  • Taking input in the string by using scanner reference i.e "input".
  • Finally checking the condition of if and else block and calculating the length of string and assign into longest variable.
You might be interested in
FILL IN THE BLANK.
Veseljchak [2.6K]

Answer:

It is measured in megahertz (MHz) and gigahertz (GHz).

Hope this helps.

3 0
3 years ago
Dominick has been hired to design a network for Pirate Press. In a paragraph of no less than 125 words, discuss what he needs to
Luda [366]
If Dominic is to design a network for Pirate Press he would have to consider and know of the following:
a. Growing capital - he needs to know if the company's sales is growing or is in debt so that he would know what course of action he could take in case he pursues projects for the company. 
b. People/Team - the people/team working are the heart and soul of any company and knowing their specific needs and how they work is key to knowing how the company works as one unit 
c. Marketing of the product - he needs to know how the product sells in order for him to decide what other strategies he can incorporate to make the product more marketable to people.

3 0
3 years ago
Read 2 more answers
Which guideline should you follow when selecting the font for a presentation?
diamong [38]
Most teachers prefer you to use Arial or Times New Roman
3 0
4 years ago
BRAINLIEST A compact disc stores information on a plastic ______________________________ with billions of pits? 100PTS
Cloud [144]

Answer:

area

Explanation:

7 0
3 years ago
Read 2 more answers
Write a machine code program for all the following problems. Test to make sure that they work in LC3. It's best to complete each
Usimov [2.4K]

Answer:

Following is given the solution to each part.

All the comments are given above each step so that they can make the logic clear.

I hope it will help you!

Explanation:

8 0
3 years ago
Other questions:
  • Given the following code fragment, how many times does the loop body execute? int laps = 50; int myNum = 1; do { myNum = myNum +
    9·1 answer
  • Write an application to pre-sell a limited number of theatre tickets. Each buyer can buy as many as 6 tickets. No more than 178
    5·1 answer
  • Write the definition of a function printLarger, which has two int parameters and returns nothing. The function prints the larger
    7·1 answer
  • What are some options available in the Spelling and Grammar Checker in word?
    6·1 answer
  • Como se llama este icono de word
    9·1 answer
  • Given the following table of students, assignments, and grades for a single class:
    6·1 answer
  • A. Choose the correct answer.
    8·2 answers
  • Which of the following situations is least likely fair use
    6·2 answers
  • How can you check data on devices connected through an iot network?
    8·2 answers
  • Utility software is used to maintain a computer.(yes or no)​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!