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 are two techniques used to indent a paragraph?
Wewaii [24]
You could hit tab or you could hit the space bar
4 0
4 years ago
Read 2 more answers
Which of the following is likely the cause of the bass from a sound system rattling the windows on your car?
Andrei [34K]
The vibration of the sound system
4 0
3 years ago
What product launch helped make blogging a more lucrative endeavor?
miss Akunina [59]
I'd say Google AdSense.

With blogging, you can make a lot of cash by showing AdSense on your pages. Google AdSense was designed with blog publishers and websites in mind and anyone who creates their own blog can take advantage of this awesome opportunity.

By allowing ads on your blog, you are able to create a static revenue stream.





3 0
3 years ago
4. How bioaugmentation helps during algal bloom.​
Aleksandr [31]
BIO-Lair sustains a higher concentration of bacteria in the water that outcompete HAB for nutrients. The presence of Bacillus bacteria can also reduce sediment thickness. Bacteria are known to help control harmful algae blooms (HAB) and also reduce organics in bottom sediments.
3 0
3 years ago
Read 2 more answers
Why is special code needed for <?
IRINA_888 [86]
The guy above is right!!!
3 0
3 years ago
Other questions:
  • Suggest two other subtasks that may be performed in a dice game?
    15·2 answers
  • A user has been given Full Control permission to a shared folder. The user has been given Modify permission at the NTFS level to
    11·1 answer
  • List 5 different programming languages calls to print
    8·2 answers
  • The elements of an integer-valued array can be set to 0 (i.e., the array can be cleared) recursively as follows: An array of siz
    8·1 answer
  • Given the strings s1 and s2 that are of the same length, create a new string consisting of the first character of s1 followed by
    12·1 answer
  • You are troubleshooting a mobile device with no sound output from the headset or external speakers.
    6·1 answer
  • How Much Memory Did the First Computers Have?
    5·1 answer
  • Need help asap please​
    13·1 answer
  • Plz answer it’s timed
    6·1 answer
  • Explain two consequences that would occur, if the "Device Manager and the "File Managerstopped communicating with each other?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!