answer.
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]
1 year 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]1 year 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]1 year 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
Use the image below to answer this question.
Leviafan [203]

Answer:

The question given is incomplete as it does not contains the image. I have found the image of the question and it is attached below.

The solution of the question is also attached below in the image.

I hope it will help you!

Explanation:

4 0
1 year ago
Write a print statement that displays a random integer between 5 and 5000. Assume the random library is imported.
Contact [7]

Answer:

Explanation:

The following code is written in Java. It is a very simple three line statement (assuming that the random library was imported) that chooses a random integer value between 5 and 5000 and prints it to the screen using the println statement.

Random rand = new Random();

int randomNum = rand.nextInt((5000 - 5) + 1) + 5;

System.out.println(randomNum);

The random number generator is initialized and given a value between 5 and 5000. Since random number Generator will generate a number between 0 and the given value then subtracting 5 from the initial generated number makes sure that it is not more than 5000 and then adding 1 and 5 after wards makes sure that it is more than 5 always.

4 0
1 year ago
6.4 Predicting Prices of Used Cars. The file ToyotaCorolla.csv contains data on used cars (Toyota Corolla) on sale during late s
Brums [2.3K]

Answer:

Compare the predictions in terms of the predictors that were used, the magnitude of the difference between the two predictions, and the advantages and disadvantages of the two methods.

Our predictions for the two models were very simmilar. A difference of $32.78 (less than 1% of the total price of the car) is statistically insignificant in this case. Our binned model returned a whole number while the full model returned a more “accurate” price, but ultimately it is a wash. Both models had comparable accuracy, but the full regression seemed to be better trained. If we wanted to use the binned model I would suggest creating smaller bin ranges to prevent underfitting the model. However, when considering the the overall accuracy range and the car sale market both models would be

Explanation:

8 0
2 years ago
Frequency of failure and network recovery time after a failure are measures of the _______ of a network.
coldgirl [10]
Frequency of a failure and network recovery time after a failure are measures of the Reliability of a network
8 0
1 year ago
Type the correct answer in the box. Spell all words correctly.
wlad13 [49]

Ryan should apply a filter/criteria on the Courses column and view all the courses that show Sociology

3 0
1 year ago
Other questions:
  • Isabel is creating a wireframe. She has drawn a layout for the home page along with outlining the navigation elements. She now w
    15·2 answers
  • Suppose the information content of a packet is the bit pattern 1110 0110 1001 1101 and an even parity scheme is being used. What
    15·1 answer
  • Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the givenprogram:Gus Bob Zoeshort_names
    13·1 answer
  • Write an expression that will cause the following code to print "18 or less" if the value of user_age is 18 or less. Write only
    9·2 answers
  • In this exercise, you will create a couple of helper methods for ArrayLists in a class called ArrayListMethods.
    10·1 answer
  • Represent the logic of a program that allows the user to enter a value for one edge of a cube. The program calculates the surfac
    10·1 answer
  • Budget Analysis (use while loop) Write a program that asks the user to enter the amount that he or she has budgeted for a month.
    5·1 answer
  • In below freezing conditions, keep your fuel level at least _________ full to keep moisture from freezing in your gas line.
    13·1 answer
  • In this question, you will experimentally verify the sensitivity of using a precise Pi to the accuracy of computing area. You ne
    14·1 answer
  • 3. Write a program to find the area of a triangle using functions. a. Write a function getData() for user to input the length an
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!