Chapter 1 |
Tasks for the first chapter
- Read the course description. Pay attention to the:
- course objectives
- rules and requirements
- grading system
- Study the materials of Chapter 1 (all parts).
- Install JDK 13 and IntelliJ on your computer.
Task 1
Rewrite the following Python program into Java:
print('Hello, World!')
Task 2
Rewrite the following Python program into Java:
fahr = float(input('Enter the temperature in F: ')) cel = round((fahr - 32) * 5/9, 2) print('The temperature in C is:', cel)
Task 3
- Create variables for integers:
a
,b
,c
,d
,f
,e
. - Assign variable
a
value2147483647
. Assign the rest of the variables any integers. - Sum, subtract, multiply, divide variables and find the reminder.
- What is the result if variable
a
is added value 1? Explain the answer in the program comment. - What is the result of the statement
System.out.println(1-0.9);
? Explain the answer in the program comment.
Hint: you can output the result of calculations using the following statement:
System.out.println("Sum of numbers " + b + " and " + c + " is " + (b + c));
What will change if the parenthesis are removed?
Task 4
Create a program which asks the user for his/her name and greets the user by the name.
Hint: use Scanner to ask the user for the name.
Make sure your programs are correct and clean, and submit them in Moodle.
Chapter 1 |