Write a program that asking the user to enter 5 numbers. Then, at the end, your program should display the count the number of positive, negative and zero entered. You should use For-loop statement.
undefined
Note:
undefined
1.Paste your editable code for the question answer and Include the screenshot of your code’s output as a part of your answer. Otherwise, you will be marked zero for this question.
undefined
2.Example of output is shown below.
undefined
Question Tow
undefined
Each of the following Java code contains one or more syntax/logical error(s). Find the error(s) and modify the code so that it will work properly. The first one is given as an example to you.
undefined
#Original CodeCorrect Code
undefined
1.for(j =0; j<=10,j++);
undefined
System.out.print(j + ” “) for(int j =0; j<=10;j++)
undefined
System.out.print(j + ” “);
undefined
2.double[] numbers = new int[5]
undefined
3.ArrayList<Integer> names = new ArrayList<Integer>();
undefined
names.add(“Ahmad”);
undefined
System.out.println(names.length);
undefined
4.int[4] myarr = {2, 9, 4, 5};
undefined
for (int i = 0; i < myarr.length(); i++)
undefined
System.out.println(myarr[i]);
undefined
5.String[] names = {‘Ali’, ‘Mohand’};
undefined
for (int i : names)
undefined
System.out.print(i + ” “);
undefined
Question Three
undefined
Write a complete java program by using for loop to print even number from 2 to 20. The output should be as following:
undefined
Note:
undefined
1.Paste your editable code for the question answer and Include the screenshot of your code’s output as a part of your answer. Otherwise, you will be marked zero for this question.
undefined
2.Example of output is shown below.
undefined
Question Four
undefined
Write a complete java program to calculate the total values of all the elements in an array.
undefined
Example: For the following input values for the array {2,6,8,3,2,2,1}, the output should be:
undefined
Note:
undefined
Paste your editable code for the question answer and Include the screenshot of your code’s output as a part of your answer.


0 comments