# <p style="text-align: center">**Programming I Chapter 1**</p>
## <p style="text-align: center">**Intorduction to Programming**</p>
<p style="text-align: right">2022/04/17</p>
---
In this chapter, we are going to have an introduction about computers, programs, and programming, after this chapter you should be able to:
## Chapter Objectives:
* Understand the basic concepts of computer memory.
* Understand how programs run.
* Be able to write a Java program.
* Be able to compile Java programs.
* Be able to fix syntax errors.
* Be able to run and test Java Programs.
## Introduction:
### What is a Program:
How do these programs work?
First of all, we write instructions to the computer to execute, as you know the computer won’t understand the regular English Text, so we write a text that is between English and Maths, this code also is very hard for the computer to execute.
But there’s a magic program `(Compilers, Interpreters)` that converts your source code to machine code, the machine code is just a binary that your CPU could understand and execute easily.

<p style="text-align: center">Figure 1: From Problem to Machine.</p>
## Introduction to Java Programming:
### How Java Programs Work:
In Java, we write a java (`source code`) file `(.java)`, which is a text file (You can use any IDE to write code for example use netbeans).
Then this code will be compiled using Java Compiler to an intermediate code (`Bytecode`) file `(.class)`.
This intermediate code will be executed using a program called Java Runtime Environment, the JRE specifically the `JVM` will translate the code to machine code.

<p style="text-align: center">Figure 2: How Java Programs Work.</p>
### Complete Your First Java Source Code!
1. Open netbeans or any other IDE, and paste the following code:
```java=
public class MyProgram {
public static void main(String[] args) {
System.out.println("Hi This is my first program!");
}
}
```
2. Run your Program:
You might notice that the line `System.out.println`, will print the text between the quotations.
`'println' is the method name`
---
## Chapter 1 Assignment:
### Task 1: Compile and fix the following code.
`This program is supposed to compute your age`
``` javascript=
import java.util.Scanner;
public class Task1 {
public static void main(String[] args){
System.out.print("Enter your birthyear: );
Scanner input = new Scanner (System.out);
int year = input.nextInt();
int age = 2022 - year
System.out.println("You are " + age +" years old");
}
}
```
### Task 2: Write your first program.
You should write a program that solves the following equation and prints it.
## `The equation:` ==$\frac {5*4+4}{10+2}$==

<p style="text-align: center">Task 2 expected output</p>
==Note==: you should calculate the result in code (Don’t print number 2! :wink: ).
---
### Solve the assignment, then submit your asnwers [`Submit here!`](https://forms.gle/4vjM5eCnAWmSwpuJ7)
### The deadline is on `Thursday 21/4/2022 at 12:00 am.`
###### `For more practice look at Chapter 1 questions Page: 52,53 at the attatched book.`
# <p style="text-align: center">**END OF CHAPTER 1**</p>
###### tags: `Java 1` `Programming 1` `Chapter 1`