IT Project Thors
IT Project Thors
Query:
sql
Explanation: This query retrieves all columns and records from the employees
table.
Output:
Query:
sql
Explanation: This query retrieves only the name and age columns of all
employees.
Output:
| name | age |
|-------------|-----|
| John Smith | 30 |
| Jane Doe | 25 |
| Robert Lee | 40 |
| Emily Davis | 28 |
| Michael Roy | 35 |
Query:
sql
Explanation: This query counts the total number of rows in the employees
table.
Output:
| COUNT(*) |
|----------|
| 5 |
Query:
sql
Explanation: This query calculates the average salary of all employees in the
table.
Output:
| AVG(salary) |
|-------------|
| 61400 |
Query:
sql
Explanation: This query returns the highest salary in the employees table.
Output:
| MAX(salary) |
|-------------|
| 75000 |
sql
Explanation: This query returns the lowest salary in the employees table.
Output:
| MIN(salary) |
|-------------|
| 50000 |
Query:
sql
Explanation: This query retrieves all employees who work in the IT department.
Output:
Query:
sql
Output:
| department |
|------------|
| HR |
| IT |
| Finance |
Query:
sql
Explanation: This query retrieves the name of employees who are older than 30
years.
Output:
| name |
|-------------|
| Robert Lee |
| Michael Roy |
Query:
sql
Output:
| name | salary |
|-------------|--------|
| Robert Lee | 75000 |
| Emily Davis | 65000 |
| Jane Doe | 60000 |
| Michael Roy | 52000 |
| John Smith | 50000 |
11. Instruction: Retrieve the first 3 records from the employees table.
Query:
sql
Explanation: This query retrieves the first 3 records from the employees table.
Output:
Query:
sql
Query:
sql
UPDATE employees
SET salary = 70000
WHERE id = 2;
Query:
sql
Query:
sql
Explanation: This query retrieves employees whose age is between 25 and 35,
inclusive.
Output:
| name | age |
|-------------|-----|
| Jane Doe | 25 |
| Emily Davis | 28 |
| Michael Roy | 35 |
15 Java Programs and their outputs:
Program:
java
Output:
Hello World
Program:
java
Explanation: This program adds two numbers, a and b, and prints the sum.
Output:
Sum: 15
Program:
java
Explanation: This program compares two numbers and prints the larger one.
Output:
20 is the largest
Program:
java
Output:
1
2
3
4
5
6
7
8
9
10
Program:
java
Explanation: This program calculates and prints the sum of two numbers.
Output:
Sum: 15
Program:
java
Explanation: This program reverses the string "Hello" and prints it.
Output:
Reversed: olleH
Program:
java
Explanation: This program checks if a number is even or odd and prints the result.
Output:
10 is even
8. Instruction: Find the factorial of a number.
Program:
java
Explanation: This program calculates the factorial of a number and prints it.
Output:
Factorial: 120
Program:
java
Output:
Sum of elements: 15
Program:
java
Output:
Program:
java
public class NumberSign {
public static void main(String[] args) {
int number = -5;
if (number > 0) {
System.out.println(number + " is
positive");
} else if (number < 0) {
System.out.println(number + " is
negative");
} else {
System.out.println("The number is zero");
}
}
}
Output:
-5 is negative
Program:
java
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
...
7 * 10 = 70
Program:
Java
Output:
Largest number: 7
Program:
java
public class PrimeNumber {
public static void main(String[] args) {
int number = 7;
boolean isPrime = true;
for (int i = 2; i <= Math.sqrt(number); i++) {
if (number % i == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
System.out.println(number + " is prime");
} else {
System.out.println(number + " is not
prime");
}
}
}
Output:
7 is prime
Program:
java
Output:
1. W3Schools
W3Schools was used as a reference for learning and understanding
the basics of MySQL and Java.
o MySQL Tutorial: https://www.w3schools.com/sql/
o Java Tutorial: https://www.w3schools.com/java/
2. GeeksforGeeks
GeeksforGeeks provided additional examples and explanations for
both MySQL queries and Java programs.
o MySQL: https://www.geeksforgeeks.org/mysql-tutorial/
o Java: https://www.geeksforgeeks.org/java/