السلام عليكم
اريد حل هذه البرامج ارجو مساعدتكم في حلها في اقرب وقت
1. Write a program that will print to the screen all the even numbers between 0 to 100
int [ ] num = {1, 2, 3, 4, 5, 10};
3. Write a java program to Evaluate the following expressions where b=2, c=3,d=4
i. a=c/(d-b)
ii. a=b*c + c*(d/b + 5)
iii. a=b*b + d%(c-b)
4. Assume that this program will compile and run correctly, what output will it produce on the screen?
public class SwitchClass
{
public static void main(String[] s)
{
int choice = 10;
switch( choice )
{
case 5:
System.out.println("CASE5");
break;
case 10:
System.out.print("CASE10");
case 15:
System.out.print("CASE15");
default:
System.out.println("DEFAULT");
}
}
}
5. Correct and write the output of the following code?
class SwitchDemo2 {
public static void main(String[] args) {
month = 2;
year = 2000;
numDays = 0;
switch (month) {
case 1: case 3: case 5:
case 7: case 8: case 10:
case 12:
numDays = 31;
break;
case 4: case 6:
case 9: case 11:
numDays = 30;
break;
case 2:
if (((year % 4 == 0) &&
!(year % 100 == 0))
|| (year % 400 == 0))
numDays = 29;
else
numDays = 28;
break;
default:
System.out.println("Invalid month.");
break;
}
System.out.println("Number of Days = "
+ numDays);
}
}
-
Consider the following code snippet.
arrayOfInts[j] > arrayOfInts[j+1]
Which operators does the code contain?
7. Suppose A, B, C are arrays of integers of size M, N, and M + N respectively. The numbers in array A appear in ascending order while the numbers in array B appear in descending order. Write a java program to produce third array C by merging arrays A and B in ascending order. Use A, B and C as arguments in the function.
8. In a company an employee is paid as under:
If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary
and DA = 90% of basic salary.
If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500
and DA = 98% of basic salary.
If the employee's salary is input by the user write a program to find his gross salary.
9. Write a program to find the roots of and quadratic equation of type ax2+bx+c where a is not equal to zero
10. Write a program to check given number is prime or not.
11. Write a java program to display the following
212
32123
4321234
543212345
12. What is the output of the following code?
class example{
public static void main(String args[])
{
int row=6;
int col=6;
int i,j;
for(i=1;i<=row;i++)
{
for(j=1;j<=col;j++)
{System.out.println(i*j);}
System.out.println(” ”);
}}}
13. Write the output of the following code?
int a=3,b=3
for(int i=1;j<=a;i++)
{
for(int j=1;j<=i;j++)
{
System.out.println(”*”);}
System.out.println(”\n”’);
}
}