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
What does the Autosum feature on excel do?
BabaBlast [244]
The answer is 1. Pressing the Autosum button highlights the ten cells above it so that you can easily add things together. Hope this helps!
8 0
3 years ago
Is using abbreviations and symbols in social media a problem? Why or why not?
Ugo [173]
The correct answer is..A? 
5 0
3 years ago
When saving a document or drawing, you determine the destination folder in which the file will be saved by?
bekas [8.4K]

making a selection in the Save in: box.<span>

</span>
8 0
3 years ago
Why isn't my brainly camera working? I got Brainly Plus and can't even scan questions. I've logged out, I've uninstalled and rei
N76 [4]

Answer:

Try resetting your device.

Explanation:

In order to send and receive iMessages to your iPhone, iMessage must be enabled. By doing this, you will associate your phone number with the email address used for your Apple ID or iCloud account.

8 0
3 years ago
The rod and crankshaft convert the up-and-down motion of the piston into
OLEGan [10]
Yes and that is correct
7 0
3 years ago
Read 2 more answers
Other questions:
  • Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outpu
    9·1 answer
  • How to upload themes to chrome web store
    11·1 answer
  • 5. Drawing Conclusions If you were a person in
    10·1 answer
  • Write a function safeOpen() that takes one parameter, filename — a string giving the pathname of the file to be opened for readi
    15·1 answer
  • At Chicago Cubs games, residents across the street from Wrigley Field can watch the game from their apartment windows. Many of t
    14·1 answer
  • Write 4 types of viruses , explain them briefly.
    7·1 answer
  • Assessment
    12·1 answer
  • What is the output for the following program?
    6·1 answer
  • Discuss the advantages and disadvantages of supporting links to files that cross mount points (that is, the file link refers to
    6·1 answer
  • Question 8 of 10
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!