Java training #1

The Purpose of this training is to get familiar with:

  • Numbers and simple calculations
  • For loops
  • If statements
  • Switch case statements
  • Reading input from the user (console) and writing output back to the screen

  1. Create a program that gets a number as an input from the user and calculates the sum of all the numbers from 1 till the input number.

  2. Create a program that gets 2 numbers as an input from the user and a string as an action (“add”, “subtract”, “multiply”, “divide”) and prints the outcome of the relevant action.
  3. Create a program that gets a number as an input from the user and prints to the screen the factorial of the number, and weather this number is primary or not.

Note: These are calculation exercises – no need for fancy classes and objects– We’ll get to that later.