Skip to content

Commit 351b8fe

Browse files
author
fouad
committed
Update
1 parent d151d08 commit 351b8fe

File tree

221 files changed

+19795
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+19795
-0
lines changed

OperatorsInJava/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OperatorsInJava/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OperatorsInJava/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OperatorsInJava/OperatorsInJava.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class AdditionOperator {
2+
3+
public static void main(String[] args) {
4+
5+
int a =5 ;
6+
int b = 7;
7+
int c = a+b +7+8+9;
8+
String m ="fouad";
9+
String s = "fofo";
10+
System.out.println(c);
11+
System.out.println(m+" khelifi "+s);
12+
13+
}
14+
}

OperatorsInJava/src/Arrays.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.Scanner;
2+
3+
public class Arrays {
4+
public static void main(String[] args) {
5+
6+
/* int [] myNumbers = {10,20,30,40,50,60,70};
7+
8+
myNumbers[2]=150;
9+
System.out.println(myNumbers.length);
10+
11+
for (int index = 0 ;index < myNumbers.length;index++){
12+
System.out.println(myNumbers[index]);
13+
}*/
14+
15+
/* for (int el :myNumbers)
16+
System.out.println(el);*/
17+
18+
int[] myNumbers = new int[5];
19+
Scanner reder =new Scanner(System.in);
20+
for (int index = 0; index < myNumbers.length;index++){
21+
System.out.println("enter number" + (index+1));
22+
myNumbers[index]=reder.nextInt();
23+
}
24+
25+
for (int index= myNumbers.length -1 ;index >= 0; index-- ){
26+
System.out.println(myNumbers[index]);
27+
}
28+
}
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class AssignmentOperator {
2+
public static void main(String[] args) {
3+
int a;
4+
String b = "fouad";
5+
a = 5;
6+
System.out.println(b);
7+
a = 7;
8+
System.out.println(a);
9+
}
10+
11+
}

OperatorsInJava/src/Comment.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import java.util.Scanner;
2+
3+
public class Comment {
4+
5+
public static void main(String[] args) {
6+
//هذا البرنامج يقوم بحساب عامل عدد
7+
int a = 5;
8+
int factorial = 1;
9+
for (int i = 1;i <= a ;i++){
10+
factorial *= i ;
11+
}
12+
System.out.println(factorial);
13+
Scanner reder = new Scanner(System.in);
14+
System.out.println("please enter a number");
15+
int month = reder.nextInt();
16+
17+
String monthString;
18+
switch (month) {
19+
case 1:
20+
monthString = "January";
21+
break;
22+
case 2:
23+
monthString = "Februry";
24+
break;
25+
case 3:
26+
monthString = "March";
27+
break;
28+
case 4:
29+
monthString = "April";
30+
break;
31+
case 5:
32+
monthString = "May";
33+
break;
34+
case 6:
35+
monthString = "June";
36+
break;
37+
case 7:
38+
monthString = "July";
39+
break;
40+
case 8:
41+
monthString = "August";
42+
break;
43+
case 9:
44+
monthString = "September";
45+
break;
46+
case 10:
47+
monthString = "October";
48+
break;
49+
case 11:
50+
monthString = "November";
51+
break;
52+
case 12:
53+
monthString = "December";
54+
break;
55+
default:
56+
monthString = "Invalid month";
57+
break;
58+
}
59+
System.out.println(monthString);
60+
}
61+
62+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class DivisionOperator {
2+
3+
public static void main(String[] args) {
4+
5+
int a = 5;
6+
int b =3;
7+
// int c = a/b; =1
8+
float c =(float) a/b;
9+
//float c = a/b; =1.0
10+
int s = a%b;
11+
float v = a/b;
12+
System.out.println("c: "+c);
13+
System.out.println("s: "+s);
14+
System.out.println(v);
15+
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class IncrementOperator {
2+
3+
public static void main(String[] args) {
4+
5+
int a = 5 , b =3 ;
6+
a++;
7+
b--;
8+
System.out.println(a);
9+
System.out.println(b);
10+
}
11+
}

OperatorsInJava/src/Loops.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import java.util.Scanner;
2+
public class Loops {
3+
public static void main(String[] args) {
4+
byte age;
5+
String name;
6+
Scanner reader = new Scanner(System.in);
7+
System.out.println("enter your name");
8+
name = reader.nextLine();
9+
// if (age == 0) System.out.println("your age is invalid");
10+
//if (age == 0){
11+
//if (age <= 0){
12+
//if (age < 0){
13+
//if (age >= 0){
14+
//if (age > 0){
15+
do {
16+
System.out.println("anter your age");
17+
age = reader.nextByte();
18+
} while (age <= 0 || age >=120);
19+
20+
if (age<=0 || name.isEmpty() || age>120){
21+
if (age <=0 || age>=120){
22+
System.out.println("your age is invalid");
23+
}
24+
if (name.isEmpty()){
25+
System.out.println("your name is invalid");
26+
}
27+
}else {
28+
System.out.println("hi " + name + " your age is "+ age);
29+
}
30+
if (age>=1&&age<=13){
31+
System.out.println("you are a child");
32+
}else if (age>=13&&age<=18){
33+
System.out.println("you are a youg");
34+
}else if (age>=18){
35+
System.out.println("you are adult");
36+
}
37+
int sum = 0;
38+
for (int index = 1;index<=age;index++){
39+
sum = sum + index;
40+
}
41+
System.out.println("sum is : " + sum);
42+
43+
for (int index = 1; index <= age ; index ++) {
44+
if (index % 2 == 0) {
45+
int factorial = 1;
46+
for (int j =1 ; j<= index; j++){
47+
factorial=factorial*j;
48+
//factorial*=j;
49+
}
50+
System.out.println(index +":"+factorial);
51+
}
52+
}
53+
//if (age != 0){
54+
// System.out.println("hi " + name + " your age is "+ age);
55+
//}else {
56+
// System.out.println("your age is valid");
57+
// System.out.println("your age is invalid");
58+
//}
59+
}
60+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class MultiplicatonOperator {
2+
public static void main(String[] args) {
3+
4+
int a =5 ,b = 3 , c = a*b*2+5;
5+
6+
System.out.println(c);
7+
}
8+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.util.Scanner;
2+
public class ReaderExample {
3+
public static void main(String[] args) {
4+
Scanner reader = new Scanner(System.in);
5+
System.out.println("enter your name");
6+
String name = reader.nextLine();
7+
System.out.println("anter your age");
8+
byte age = reader.nextByte();
9+
// if (age == 0) System.out.println("your age is invalid");
10+
//if (age == 0){
11+
//if (age <= 0){
12+
//if (age < 0){
13+
//if (age >= 0){
14+
//if (age > 0){
15+
if (age<=0 || name.isEmpty() || age>120){
16+
if (age <=0 || age>=120){
17+
System.out.println("your age is invalid");
18+
}
19+
if (name.isEmpty()){
20+
System.out.println("your name is invalid");
21+
}
22+
}else {
23+
System.out.println("hi " + name + " your age is "+ age);
24+
}
25+
if (age>=1&&age<13){
26+
System.out.println("you are a child");
27+
}else if (age>=13&&age<18){
28+
System.out.println("you are a youg");
29+
}else if (age>=18){
30+
System.out.println("you are adult");
31+
}
32+
//if (age != 0){
33+
// System.out.println("hi " + name + " your age is "+ age);
34+
//}else {
35+
// System.out.println("your age is valid");
36+
// System.out.println("your age is invalid");
37+
38+
//}
39+
}
40+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public class StringExampes {
2+
public static void main(String[] args) {
3+
4+
String welcom = " Welcom to fouad land ";
5+
System.out.println(welcom.length());
6+
System.out.println(welcom.charAt(0));
7+
System.out.println(welcom.indexOf("f"));
8+
System.out.println(welcom.indexOf("a",14));
9+
System.out.println(welcom.lastIndexOf("to"));
10+
String SubText = welcom.substring(10);
11+
System.out.println(SubText);
12+
System.out.println(welcom.substring(10));
13+
System.out.println(welcom.substring(10,15));
14+
System.out.println(welcom.replace("a","X"));
15+
System.out.println(welcom.replaceFirst("a","X"));
16+
System.out.println(welcom.toUpperCase());
17+
System.out.println(welcom.toLowerCase());
18+
// welcom = welcom.toUpperCase();
19+
//System.out.println(welcom);
20+
System.out.println(welcom.trim());
21+
System.out.println(welcom.contains("fouad"));
22+
System.out.println(welcom.startsWith(" "));
23+
System.out.println(welcom.endsWith(" "));
24+
25+
}
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class SubtractionOperator {
2+
3+
public static void main(String[] args) {
4+
5+
int a = -5 ;
6+
int b = -3 ;
7+
int c = b-a;
8+
c = -c;
9+
System.out.println(c);
10+
}
11+
}

0 commit comments

Comments
 (0)