باستخدام for loop أوجد قيمة x
اذا علمت ان :
x = 1!+3!+5!+7!
اذا علمت ان :
x = 1!+3!+5!+7!
import java.util.*;
public class Main
{
public static void main ( String[] args )
{
int f = 1, Sum = 0;
for ( int i = 1; i <= 7; i++ )
{
if ( i % 2 != 0 )
{
f = f * i;
Sum += f;
System.out.println ( "sum of factorial is : " + Sum );
}
}
// System.out.println ( "sum of factorial is : " + Sum );
}}
public class Main
{
public static void main ( String[] args )
{
int f = 1, Sum = 0;
for ( int i = 1; i <= 7; i++ )
{
if ( i % 2 != 0 )
{
f = f * i;
Sum += f;
System.out.println ( "sum of factorial is : " + Sum );
}
}
// System.out.println ( "sum of factorial is : " + Sum );
}}
الواجب ----السؤال الأول- ------- 01-12-2022 👇
💻💻💻💻💻💻💻💻💻💻💻💻
اكتب برنامج لحساب قيمة z
حيث
z=x^n/n!
ثم تابع سير البرنامج يدويا بالتفصيل
💻💻💻💻💻💻💻💻💻💻💻💻
اكتب برنامج لحساب قيمة z
حيث
z=x^n/n!
ثم تابع سير البرنامج يدويا بالتفصيل
الواجب ----السؤال الثاني-------- 01-12-2022 👇
💻💻💻💻💻💻💻💻💻💻💻💻
اكتب برنامج لحساب قيمة X
حيث
X=a/1! + x^2 / 2! + x^3 / 3!
ثم تابع سير البرنامج يدويا بالتفصيل
💻💻💻💻💻💻💻💻💻💻💻💻
اكتب برنامج لحساب قيمة X
حيث
X=a/1! + x^2 / 2! + x^3 / 3!
ثم تابع سير البرنامج يدويا بالتفصيل
كون مصفوفه تحتوي على 7 قيم ثم اطبع كل قيمه مع الموقع المقابل لها
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Integer []a = new Integer[] {9,8,7,6,5,4,3};
for (int i= 0;i<7;i++)
{
System.out.println("a["+i+"]= "+ a[i]);
}
}
}
public class Main
{
public static void main(String[] args)
{
Integer []a = new Integer[] {9,8,7,6,5,4,3};
for (int i= 0;i<7;i++)
{
System.out.println("a["+i+"]= "+ a[i]);
}
}
}
السؤال الثاني
كون مصفوفه تحتوي على 7 قيم ثم اطبع القيم الفرديه مع المواقع المقابله لها
كون مصفوفه تحتوي على 7 قيم ثم اطبع القيم الفرديه مع المواقع المقابله لها
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Integer []a = new Integer[] {9,8,7,6,5,4,3};
for (int i= 0;i<7;i++)
{
if(i%2!=0)
{
System.out.println("a["+i+"]= "+ a[i]);
}
}
}
}
public class Main
{
public static void main(String[] args)
{
Integer []a = new Integer[] {9,8,7,6,5,4,3};
for (int i= 0;i<7;i++)
{
if(i%2!=0)
{
System.out.println("a["+i+"]= "+ a[i]);
}
}
}
}
السؤال الثالث
كون مصفوفه تحتوي على 7 قيم ثم اطبع كل الموقع فقط بدون القيم
كون مصفوفه تحتوي على 7 قيم ثم اطبع كل الموقع فقط بدون القيم
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Integer []a = new Integer[] {9,8,7,6,5,4,3};
for (int i= 0;i<7;i++)
{
System.out.println("a["+i+"]= ");
}
}
}
public class Main
{
public static void main(String[] args)
{
Integer []a = new Integer[] {9,8,7,6,5,4,3};
for (int i= 0;i<7;i++)
{
System.out.println("a["+i+"]= ");
}
}
}
السؤال الرابع
اكتب برنامج يطلب من المستخدم إدخال طو ل المصفوفه
ثم يدخل قيم المصفوفه
ثم يضرب قيم المصفوفه * 2
ثم يطبع الناتج مع المواقع المقابله لها
اكتب برنامج يطلب من المستخدم إدخال طو ل المصفوفه
ثم يدخل قيم المصفوفه
ثم يضرب قيم المصفوفه * 2
ثم يطبع الناتج مع المواقع المقابله لها
import java.util.*;
public class Main
{
public static void main(String[] args)
{
System.out.println("مرحبا بكم في المصفوفات");
Scanner input = new Scanner(System.in);
System.out.print("Enter a array lengh: ");
int l= input.nextInt();
int []a= new int[l];
System.out.println("Enter array elements: ");
//loop to enter an array elements
for(int i=0;i<a.length;i++)
{
System.out.print("a["+i+"]= ");
a[i]=input.nextInt();
}
// loop to an output an array elements
for(int j =0;j<a.length;j++)
{
a[j]*=2;
System.out.println("An array Elements is a["+j+"] = " + a[j]);
}
}
}
public class Main
{
public static void main(String[] args)
{
System.out.println("مرحبا بكم في المصفوفات");
Scanner input = new Scanner(System.in);
System.out.print("Enter a array lengh: ");
int l= input.nextInt();
int []a= new int[l];
System.out.println("Enter array elements: ");
//loop to enter an array elements
for(int i=0;i<a.length;i++)
{
System.out.print("a["+i+"]= ");
a[i]=input.nextInt();
}
// loop to an output an array elements
for(int j =0;j<a.length;j++)
{
a[j]*=2;
System.out.println("An array Elements is a["+j+"] = " + a[j]);
}
}
}
👍1