Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Task 1 - String variables

  1. Create a new project and call it VariablesExercise.

  2. Within the main method, declare two String variables - firstName and lastName.

  3. Assign values to the variables above.

  4. Create another variable called name and assign it a concatenated value of the two previous variables.

  5. Print out name.

Task 2 - Numbers

  1. Comment out the code from the previous task.

  2. Create two integer variables, call them num1 and num2.

  3. Assign them a valid literal value.

  4. Print out their sum.

  5. Create another integer variable - result. Assign it the result of division between num1 and num2. Does it work? Can you fix it?

  6. Create another integer variable - num3 and assign it a value 8.

  7. Print out the value of num3++.

  8. Print out the value of num3.

  9. Print out value of ++num3.

  10. Is there any difference?

Task 3 - User input

  1. Comment out all your code from the previous task.

  2. Research how to read user input from the terminal - https://www.baeldung.com/java-console-input-output

...