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
Describe how electrons move between atoms to create electricity.
pentagon [3]
Applying potential difference to a conductor, by potential force, free electrons gain energy and move from low to high potential. Thus, electrons move from one atom to another.
3 0
3 years ago
Read 2 more answers
most dialog boxes in windows programs requiring navigation follow a similar procedure. true or false.
vfiekz [6]
I believe that is true

Hope this helps!! :)

8 0
2 years ago
How does a computer resolve a domain name into an ip address?
Yanka [14]

Answer:

Using the DNS service.

Explanation:

The computer sends a UDP packet with the domain name in it to port 53 of the configured DNS server, and expects a reply with the IP address of that domain.

8 0
3 years ago
Consider the following code: x=random.randint (1, 100) The randint is a ____.​
Mrrafil [7]
Random integer, in this case betweeen 1 and 100
5 0
3 years ago
Analyze and write a comparison of C's malloc and free functions with C++'s new and delete operators. Use safety as the primary c
Alisiya [41]

Answer:

The C's malloc and free functions and the C++'s new and delete operators execute similar operations but in different ways and return results.

Explanation:

- The new and delete operators return a fully typed pointer while the malloc and free functions return a void pointer.

-The new and delete operators do not return a null value on failure but the malloc/free functions do.

- The new/delete operator memory is allocated from free store while the malloc/free functions allocate from heap.

- The new/delete operators can add a new memory allocator to help with low memory but the malloc/free functions can't.

- The compiler calculates the size of the new/delete operator array while the malloc/free functions manually calculate array size as specified.

5 0
2 years ago
Other questions:
  • Nancy would like to configure an automatic response for all emails received while she is out of the office tomorrow, during busi
    13·2 answers
  • which student organization helps students with career development by having them become interms to sponsor conferences?
    9·1 answer
  • Easy question how the internet has impacted y’all life
    13·1 answer
  • How did tafts accomplishments regarding conservation and trust-busting compare to roosevelt?
    11·1 answer
  • Which best describes the benefits of renting a home?
    10·2 answers
  • Which of these are forms of data? Check all that apply.
    8·2 answers
  • Which is an unethical use of technology and resources at the workplace?
    13·2 answers
  • How to open a new word proccessing document
    9·1 answer
  • 1. Which of the following is not true about high-level programming language s? (a) Easy to read and write (b) Popular among prog
    12·1 answer
  • Match the following pls help
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!