Module: (Java) Variables. Output formats


Problem

3/7

How input a data into variable

Theory Click to read/hide

In order for the user to be able to set the value of the variable himself, it is necessary to be able to input values from the keyboard. 
To do this, use the in object, which is written like this:

Scanner in = new Scanner(System.in); 
But for it to work, you must first import using
import java.util.Scanner

To get an integer value, use in.nextInt (); , the result of which must be assigned to a variable.
For example:
int a = in.nextInt();
For other data types, there are other methods:
  • next(): reads the input line to the first space
  • nextLine(): reads the entire entered line
  • nextInt(): reads the entered number int
  • nextDouble(): reads the entered number double
  • nextBoolean(): reads value boolean
  • nextByte(): reads the entered number byte
  • nextFloat(): reads the entered number float
  • nextShort(): сreads the entered number short

Problem

Rabbit Clover began to study the input operator, so that his programs became more universal and worked on different sets of values.
He wants to input the values of 6 variables from the keyboard and output them on the screen to make sure that they are in the necessary variables. But he made some mistakes in the program.
Help him fix them.

1. In the sixth and seventh lines, correct errors when writing input operators so that the values of the variables specified in the line are entered, use one print command in each line
2. In the eighth line, write the operator for outputing the values of all variables on the screen in alphabetical order with a one space