JAVA OOP
181 subscribers
13 photos
2 videos
1 file
9 links
شرح + حل واجبات جميع الاقسام + امثله لاتنتهي + كوزرات
للتواصل او للارسال سؤالك @sz6ss_bot
المسؤول عن القناه @sz6ss
Download Telegram
واجبات#الانظمه مسائي
JAVA OOP
واجبات#الانظمه مسائي
Q1//

mport java.util.Scanner;

public class mai {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);


System.out.print("Enter the num1 : ");
int num1 = in.nextInt();

System.out.print("Enter the num2 : ");
int num2 = in.nextInt();

System.out.print("Enter the num3 : ");
int num3 = in.nextInt();


int greatest = num1;

if (num2 > greatest) {
greatest = num2;
}


if (num3 > greatest) {
greatest = num3;
}
JAVA OOP
واجبات#الانظمه مسائي
Q2//


import java.util.Scanner;

public class main {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

double quiz;
double midTerm;
double finalScore;


while (true) {
System.out.print("Enter quiz score (0-100): ");
quiz = scanner.nextDouble();
if (quiz >= 0 && quiz <= 100) {
break;
} else {
System.out.println("Invalid score. Please enter a value between 0 and 100.");
}
}


while (true) {
System.out.print("Enter mid-term score (0-100): ");
midTerm = scanner.nextDouble();
if (midTerm >= 0 && midTerm <= 100) {
break;
} else {
System.out.println("Invalid score. Please enter a value between 0 and 100.");
}
}


while (true) {
System.out.print("Enter final score (0-100): ");
finalScore = scanner.nextDouble();
if (finalScore >= 0 && finalScore <= 100) {
break;
} else {
System.out.println("Invalid score. Please enter a value between 0 and 100.");
}
}


double averageScore = (quiz + midTerm + finalScore) / 3;


if (averageScore >= 90) {
System.out.println("Grade: A");
} else if (averageScore >= 70) {
System.out.println("Grade: B");
} else if (averageScore >= 50) {
System.out.println("Grade: C");
} else {
System.out.println("Grade: F");
}

scanner.close();
}
JAVA OOP
واجبات#الانظمه مسائي
Q3//
public class main {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 2 * i - 1; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
JAVA OOP
واجبات#الانظمه مسائي
Q4//

import java.util.Scanner;


public class main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter positive numbers (enter a non-positive to stop):");

while (true) {
int number = input.nextInt();
if (number <= 0) {
System.out.println("Terminated.");
break;
}
}
}
}
JAVA OOP
واجبات#الانظمه مسائي
Q7
public class main {
public static void main(String[] args) {
int term = 1;
for (int i = 0; i < 10; i++) {
System.out.print(term + " ");
term = term * 2 + 1;
}
}
}
سؤال المختبر القادم للهياكل /علوم صباحي
//
اكتب برنامج يقرء مصفوفه احاديه مصفوفة ثنائيه ثم يطلب من المستخدم اختيار نوع المصفوفه ووحجم المصفوفه وعناصر المجموعه ثم طباعتها واجراء 5 عمليات عليها ويبقى يطلب من المستخدم اجراء عمليات لحين طلب المستخدم الخروج من العمليات
مًحًمًدٍ
سؤال المختبر القادم للهياكل /علوم صباحي // اكتب برنامج يقرء مصفوفه احاديه مصفوفة ثنائيه ثم يطلب من المستخدم اختيار نوع المصفوفه ووحجم المصفوفه وعناصر المجموعه ثم طباعتها واجراء 5 عمليات عليها ويبقى يطلب من المستخدم اجراء عمليات لحين طلب المستخدم الخروج…
import java.util.Scanner;
public class hmd {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
boolean exit = false;

while (!exit) {
System.out.println("اختر نوع المصفوفة: 1. أحادية 2. ثنائية 3. ثلاثية 4. خروج");
int choice = scanner.nextInt();

switch (choice) {
case 1:
// مصفوفة أحادية
System.out.println("أدخل عدد العناصر في المصفوفة الأحادية:");
int size = scanner.nextInt();
int[] array = new int[size];
System.out.println("أدخل العناصر:");
for (int i = 0; i < size; i++) {
array[i] = scanner.nextInt();
}
printArray(array); // طباعة المصفوفة
arrayD1(array);
break;

case 2:
// مصفوفة ثنائية
System.out.println("أدخل عدد الصفوف:");
int rows = scanner.nextInt();
System.out.println("أدخل عدد الأعمدة:");
int cols = scanner.nextInt();
int[][] matrix = new int[rows][cols];
System.out.println("أدخل العناصر:");
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
matrix[i][j] = scanner.nextInt();
}
}
printArray(matrix); // طباعة المصفوفة
arrayD2(matrix);
break;

case 3:
// مصفوفة ثلاثية
System.out.println("أدخل عدد الطبقات:");
int layers = scanner.nextInt();
System.out.println("أدخل عدد الصفوف:");
int threesRows = scanner.nextInt();
System.out.println("أدخل عدد الأعمدة:");
int threesCols = scanner.nextInt();
int[][][] threeDMatrix = new int[layers][threesRows][threesCols];
System.out.println("أدخل العناصر:");
for (int i = 0; i < layers; i++) {
for (int j = 0; j < threesRows; j++) {
for (int k = 0; k < threesCols; k++) {
threeDMatrix[i][j][k] = scanner.nextInt();
}
}
}

break;

case 4:
exit = true;
System.out.println("تم الخروج من البرنامج.");
break;

default:
System.out.println("اختيار غير صالح.");
}
}

scanner.close();
}

// عمليات على المصفوفة الأحادية
private static void arrayD1 (int[] array) {
boolean backToMenu = false;

while (!backToMenu) {
printArray( array);
System.out.println("اختر عملية:");
System.out.println("1. حساب مجموع العناصر");
System.out.println("2. حساب متوسط العناصر");
System.out.println("3. العثور على أكبر عنصر");
System.out.println("4. العثور على أصغر عنصر");
System.out.println("5. عكس المصفوفة");
System.out.println("6. العودة إلى القائمة الرئيسية");

java
👍2
int operation = new Scanner(System.in).nextInt();
switch (operation) {
case 1:
System.out.println("مجموع العناصر: " + sum(array));
break;
case 2:
System.out.println("متوسط العناصر: " + average(array));
break;
case 3:
System.out.println("أكبر عنصر: " + max(array));
break;
case 4:
System.out.println("أصغر عنصر: " + min(array));
break;
case 5:
reverseArray(array);
break;
case 6:
backToMenu = true;
break;
default:
System.out.println("اختيار غير صالح! يرجى إدخال رقم من 1 إلى 6.");
}
}
}

// عمليات على المصفوفة الثنائية
private static void arrayD2(int[][] matrix) {
boolean backToMenu = false;

while (!backToMenu) {
printArray(matrix);
System.out.println("اختر عملية:");
System.out.println("1. حساب مجموع العناصر");
System.out.println("2. حساب متوسط العناصر");
System.out.println("3. العثور على أكبر عنصر");
System.out.println("4. العثور على أصغر عنصر");
System.out.println("5. عكس المصفوفة");
System.out.println("6. العودة إلى القائمة الرئيسية");

int operation = new Scanner(System.in).nextInt();
switch (operation) {
case 1:
System.out.println("مجموع العناصر: " + sum(matrix));
break;
case 2:
System.out.println("متوسط العناصر: " + average(matrix));
break;
case 3:
System.out.println("أكبر عنصر: " + max(matrix));
break;
case 4:
System.out.println("أصغر عنصر: " + min(matrix));
break;
case 5:
reverseMatrix(matrix);
break;
case 6:
backToMenu = true;
break;
default:
System.out.println("اختيار غير صالح! يرجى إدخال رقم من 1 إلى 6.");
}
}
}


// دالة لعكس المصفوفة الأحادية
private static void reverseArray(int[] array) {
int n = array.length;
for (int i = 0; i < n / 2; i++) {
int temp = array[i];
array[i] = array[n - i - 1];
array[n - i - 1] = temp;
}
System.out.println("المصفوفة بعد العكس:");
printArray(array);
}

// دالة لعكس المصفوفة الثنائية
private static void reverseMatrix(int[][] matrix) {
for (int i = 0; i < matrix.length; i++) {
reverseArray(matrix[i]);
}
System.out.println("المصفوفة الثنائية بعد العكس:");
printArray(matrix);
}



private static int sum(int[] array) {
int total = 0;
for (int i = 0; i < array.length; i++) {
total += array[i];
}
return total;
}

private static double average(int[] array) {
return (double) sum(array) / array.length;
}

private static int max(int[] array) {
int max = array[0];
for (int i = 0; i < array.length; i++) {
if (array[i] > max) {
max = array[i];
}
}
return max;
}

private static int min(int[] array) {
int min = array[0];
for (int i = 0; i < array.length; i++) {
if (array[i] < min) {
min = array[i];
}
}
return min;
}

private static int sum(int[][] matrix) {
int total = 0;
for (int i = 0; i < matrix.length; i++) {
total += sum(matrix[i]); // استخدام دالة sum للمصفوفة الأحادية
}
return total;
}
private static double average(int[][] matrix) {
return (double) sum(matrix) / (matrix.length * matrix[0].length);
}

private static int max(int[][] matrix) {
int max = matrix[0][0];
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
if (matrix[i][j] > max) {
max = matrix[i][j];
}
}
}
return max;
}

private static int min(int[][] matrix) {
int min = matrix[0][0];
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
if (matrix[i][j] < min) {
min = matrix[i][j];
}
}
}
return min;
}



private static void printArray(int[] array) {
System.out.println("عناصر المصفوفة الأحادية:");
for (int i : array) {
System.out.print(i + " ");
}
System.out.println();
}

private static void printArray(int[][] matrix) {
System.out.println("عناصر المصفوفة الثنائية:");
for (int[] row : matrix) {
for (int j : row) {
System.out.print(j + " ");
}
System.out.println();
}
}


}
اكتب برنامج بلغه جافا يقرء مدخلين من المستخدم واستخدم الدوال لحساب المجموع وطباعته
الكود الاخذناه بالعملي
import java.util.Scanner;

public class App {

public static Scanner read=new Scanner(System.in);
public static void main(String[] args) {

System.out.println("enter a&b:");
int a= read.nextInt();
int b=read.nextInt();
int c=multi(a,b);
output(c);
read.close();
}
public static int multi (int a,int b) {





int multi =a*b;
return multi;
}
public static void output (int c) {
System.out.println("the multi: "+c);

}
}



#مختبر علوم الحاسوب
واجبات#انظمه_صباحي
JAVA OOP
واجبات#انظمه_صباحي
باجر انزل الحلول اذا احد حاب يقوي نفسه خل يحاول يحلهن
👍2
JAVA OOP
واجبات#انظمه_صباحي
Q1
import java.util.Scanner;

public class hh {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter N : ");
int N = scanner.nextInt();
int largest = 0;

for (int i = 0; i < N; i++) {
System.out.print("Enter num" + (i + 1) + ": ");
int num = scanner.nextInt();
if (num > largest) {
largest = num;
}
}
System.out.println("Largest number: " + largest);

}
}

Q2

import java.util.Scanner;

public class hh {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of integers (N): ");
int N = scanner.nextInt();

for (int i = 0; i < N; i++) {
System.out.print("Enter number " + (i + 1) + "= ");
int num = scanner.nextInt();
if (num > 0) {
System.out.println(num + " is positive.");
} else if (num < 0) {
System.out.println(num + " is negative.");
} else {
System.out.println(num + " is zero.");
}
}
}
}

Q3
java
import java.util.Scanner;

public class hh {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of characters (N): ");
int N = scanner.nextInt();

for (int i = 0; i < N; i++) {
System.out.print("Enter character " + (i + 1) + ": ");
char ch = scanner.next().charAt(0);
if (Character.isLetter(ch)) {
System.out.println(ch + " is an alphabet.");
} else {
System.out.println(ch + " is not an alphabet.");
}
}

}
}

#
Q4
import java.util.Scanner;

public class hh {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of characters (N): ");
int N = scanner.nextInt();

for (int i = 0; i < N; i++) {
System.out.print("Enter character " + (i + 1) + ": ");
char ch = scanner.next().charAt(0);
if ("AEIOUaeiou".indexOf(ch) != -1) {
System.out.println(ch + " is a vowel.");
} else if (Character.isLetter(ch)) {
System.out.println(ch + " is a consonant.");
} else {
System.out.println(ch + " is not an alphabet.");
}
}

}
}
👍1
JAVA OOP
باجر انزل الحلول اذا احد حاب يقوي نفسه خل يحاول يحلهن
Q5
import java.util.Scanner;

public class hh {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first integer: ");
int firstNum = scanner.nextInt();
System.out.print("Enter second integer: ");
int secondNum = scanner.nextInt();
System.out.print("Enter operation (+, -, *, /): ");
char operation = scanner.next().charAt(0);

switch (operation) {
case '+':
System.out.println("Result: " + (firstNum + secondNum));
break;
case '-':
System.out.println("Result: " + (firstNum - secondNum));
break;
case '*':
System.out.println("Result: " + (firstNum * secondNum));
break;
case '/':
if (secondNum != 0) {
System.out.println("Result: " + (firstNum / (double) secondNum));
} else {
System.out.println("Cannot divide by zero.");
}
break;
default:
System.out.println("Invalid operation.");
}
scanner.close();
}
}

Q6

import java.util.Scanner;

public class hh {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter month number (1-12): ");
int month = scanner.nextInt();
int days;

switch (month) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
days = 31;
break;
case 4: case 6: case 9: case 11:
days = 30;
break;
case 2:
days = 28;
break;
default:
days = 0;
}

if (days != 0) {
System.out.println("Days in month: " + days);
} else {
System.out.println("Invalid month number.");
}

}
}
JAVA OOP
واجبات#انظمه_صباحي
import java.util.Scanner;

public class hh {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of elements: ");
int N = scanner.nextInt();
int[] numbers = new int[N];

System.out.println("Enter " + N + " numbers:");
for (int i = 0; i < N; i++) {
numbers[i] = scanner.nextInt();
}

System.out.print("Enter specific number to count: ");
int specificNum = scanner.nextInt();
int count = 0;

for (int number : numbers) {
if (number == specificNum) {
count++;
}
}
System.out.println(specificNum + " appears " + count + " times.");

}
}

Q10
import java.util.Scanner;

public class hh {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a maximum odd number (n): ");
int nValue = scanner.nextInt();

if (nValue % 2 == 1) {
int sumOdd = 0;
int oddCount = 0;

System.out.print("Odd numbers between 1 and " + nValue + ": ");
for (int i = 1; i <= nValue; i += 2) {
System.out.print(i + " ");
sumOdd += i;
oddCount++;
}
double average = oddCount > 0 ? (double) sumOdd / oddCount : 0;
System.out.println("\nAverage of odd numbers: " + average);
} else {
System.out.println("Please enter an odd number.");
}

}
}
JAVA OOP
واجبات#انظمه_صباحي
Q11
import java.util.Scanner;

public class hh {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);


System.out.print("Enter N: ");
int N = read.nextInt();
System.out.print("Enter M: ");
int M = read.nextInt();


System.out.println("Even numbers between " + N + " and " + M + ":");
for (int i = N; i <= M; i++) {
if (i % 2 == 0) {
System.out.println(i);
}
}
}
}

Q13

import java.util.Scanner;

public class hh {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);

System.out.print("Enter student's average: ");
double average = read.nextDouble();


if (average > 90) {
System.out.println("The student is eligible.");
} else {
System.out.println("The student is not eligible.");
}
}
}
JAVA OOP
واجبات#انظمه_صباحي
Q16
import java.util.Scanner;
public class hh {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.print("Enter N: ");
int N = scanner.nextInt();

System.out.println("Figure:");
for (int i = N; i > 0; i -= 4) {
for (int j = i; j > i - 4 && j > 0; j--) {
System.out.print(j + " ");
}
System.out.println();
}
}
}

**بقن كم سؤال مافهمتهن
اسماء الرموز في البرمجه بصوره عامه
👏3👍1
2_3_4_5_merged.pdf
913.2 KB
نحاول نحل هذا الملف اغلب الاقسام معتمده عليه