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]
2 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]2 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]2 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
How the data is converted into the information?​
leonid [27]

Answer:

the data is converted into information by data processing

7 0
3 years ago
Read 2 more answers
Lonic compounds are also known as <br> a. salts <br> b. valence <br> c.organic <br> d.elements
shutvik [7]
I'm not quite sure but it maybe b
6 0
3 years ago
Read 2 more answers
Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If user
Sedbober [7]

Answer:

Replace /* Your solution goes here */ with:

cin>>matchValue;

numMatches = 0;

for (i = 0; i < userValues.size(); ++i) {

if(matchValue == userValues.at(i))

{

numMatches++;

}

}

Explanation:

This line gets input for matchValue

<em>cin>>matchValue; </em>

This line initializes numMatches to 0

<em>numMatches = 0; </em>

The following iteration checks for the number of matches (numMatches) of the matchValue

<em>for (i = 0; i < userValues.size(); ++i) { </em>

<em>if(matchValue == userValues.at(i)) </em>

<em>{ </em>

<em> numMatches++; </em>

<em>} </em>

<em>} </em>

<em>See Attachment for full source code</em>

Download cpp
3 0
3 years ago
The term drive app is used to describe applications stored on a computer true or false
Volgvan
Hello <span>Areyano7475
</span>

Question: T<span>he term drive app is used to describe applications stored on a computer true or false


Answer: False


Hope this helps
-Chris</span>
7 0
3 years ago
Read 2 more answers
5. The problem domain refers to the
solong [7]

Answer:

The problem domain refers to the support options.

6 0
3 years ago
Other questions:
  • Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
    8·1 answer
  • A patient presents at an outpatient urgent care facility with an acute illness and is seen by a provider. A detailed history wit
    13·1 answer
  • Help me out with this .....
    10·1 answer
  • What's the best strategy for avoiding ATM fe
    14·1 answer
  • A customer has a computer for a home business, but wants to have another computer as a web server. What would be the best soluti
    11·2 answers
  • Given a constant named size with a value of 5, which statement can you use to define and initialize an array of doubles named ga
    12·1 answer
  • Write a C# program named ProjectedRaises that includes a named constant representing next year’s anticipated 4 percent raise for
    15·1 answer
  • Which of the following correctly orders the units of measure from least to greatest?
    7·2 answers
  • Would you consider upgrading Maxine’s wardrobe a need or a want?
    11·1 answer
  • Jjhb ft fv tuning Denise l Debbie
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!