In Windows, go to the folder in which you would like to download this repository, click on the address bar at the top
and type cmd.exe
. This will open up the command line terminal, where you will enter the following commands:
git clone https://github.com/Compec/java-2018-w2-assignment
Launch IntelliJ IDEA
and open the project by selecting the folder where you downloaded the project.
Simply press on the green button Clone or Download
in top-right corner of this page and press Download ZIP
.
Download the ZIP file then extract it with your zip program (Winrar, 7zip ...)
I do not have a mac/linux machine so I prefer not to give instructions :) The steps should be very similar though.
Write a Java program that takes a number as input and prints its multiplication table upto 10
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
...
8 x 10 = 80
A) Why 10? Make the user decide of the number
Example:
Multiplication table from 1 to ... __100__
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
...
8 x 100 = 800
Write a Java program works as a calculator. It should ask the user for two numbers and the operation to apply to them.
Enter the first real number: __ 3 __
Enter the second real number: __ 2 __
Operations possible:
- addition
- subtraction
- division
- multiplication
- remainder
Enter the operation you want to do: addition
3 + 2 = 5
A) Even if the user enters aDDitIon
instead of addition
, it should accept it
Example:
Enter the first real number: __ 3 __
Enter the second real number: __ 2 __
Operations possible:
- addition
- subtraction
- division
- multiplication
- remainder
Enter the operation you want to do: sUbTraCTIon
3 - 2 = 1
B) Keep asking the user for the operation if they keep giving wrong input
Example:
Enter the first real number: __3__
Enter the second real number: __2__
Operations possible:
- addition
- subtraction
- division
- multiplication
- remainder
Enter the operation you want to do: __exponentiation__
Sorry, this calculator cannot do `exponentation`.
Enter the operation you want to do: __division__
3 / 2 = 1.5
C) Prevent illegal operations from happening, like division by zero
Example:
Enter the first real number: __8__
Enter the second real number: __0__
Operations possible:
- addition
- subtraction
- division
- multiplication
- remainder
Enter the operation you want to do: __division__
Sorry, division by zero is undefined
C) After an operation is done, ask the user if they want to calculate something again
Enter the first real number: __3__
Enter the second real number: __2__
Operations possible:
- addition
- subtraction
- division
- multiplication
- remainder
Enter the operation you want to do: __addition
3 + 2 = 5
Would you like to calculate something else? __yes__
Enter the first real number: __7__
Enter the second real number: __17__
(...)
Write a Java program that prints all prime numbers from 1 to 100
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97
A) Make the range flexible (from a to b instead of 1 to 100)
Mehdi Saffar - LinkedIn