Study the following portion of a Jjava program and answer the questions that follows.
while(i < 4){
j = 0;
While(j < 5){
System.out.println(“Please enter the value to be stored”);
Marks[i][j] = scan.nextInt();
j++;
}
i++;
}
i)
What do we call this block of code in programming?
[5]
ii)
What is the function of this block of code?
[5]
iii)
Using a table, write out the output of these statements.
[
Write a java program that receives two values from the user, adds them together and
display the answer.
Write a java program that would display the 8 shape using the ‘*’ characte
The _________ is to visit the left subtree of the current node first, then the right subtree of the current node, and finally the current node itself.
A __________ (with no duplicate elements) has the property that for every node in the tree the value of any node in its left subtree is less than the value of the node and the value of any node in its right subtree is greater than the value of the node.
A. binary search tree
B. list
C. linked list
D. binary tre
Write the output and if there is an error correct the error first then write the output:
1.for(int a=1; a<=3; a++)
for(int b=2; b<5; b++)
out.print(a+b + " ");
2.for(int i=2; i<=6; i++){
for(int j=1; j<=i; j++)
out.print('*');
out.println();
}
3.int total = 0;
for(int c=2; c<7; c++)
for(int d=1; d<=c; d++)
total = total + d;
out.println(total);
4.String s = "apluscs";
for(int e=0; e<s.length(); e++)
{
for(int f=0;f<=e;f++){
System.out.print(s.charAt(f));
}
System.out.println();
}
5.for(int count1=1; count1 <= 5; count1++)
{
for (int count2=1; count2 <= 5; count2++)
System.out.print (count1*count2 + " ");
System.out.println();
}
6.public static void main(String args[]) {
int a,b;
a = 3;
b = 4;
System.out.println(three(a,b));
}
public static int three(int x, int y) {
int a;
a = x + y;
return a;
}
Write the output and if there is an error correct the error first then write the outp:
1.for(int i=-3; i<19; i=i+3)
{
out.print(i + " ");
}
2.for(int j=17; j>-2; j=j-2)
{
out.print(j + " ");
}
3.for(int x=20, x<50, x=x+3)
{
out.print(x + " ");
}
4.for(m=37; m>0; m=m-4)
{
out.print(m + " ");
}
5.int total=0;
for(int s=1; s<19; s++)
{
total=total+s;
}
out.println(total);
6.int x=-2;
while(x<9)
{
x++;
System.out.print(x + " ");
}
7.int m=1, total=0;
while(m<9){
total=total+m;
m++;
}
System.out.print(total );
8.int k=5;
String s="";
while(k>0){
s=k+" "+s;
k--;
}
System.out.print(s);
9.int b=3;
String list="";
while(b<10) {
b=b+2;
if(b%2==1)
list=b+" "+list;
}
System.out.print(list);
10.int num = 15, MAX = 20;
do
{
num = num + 1;
System.out.println (num);
} while (num <= MAX);
11.int num = 15, MAX = 20;
do
{
num = num + 1;
if (num*2 > MAX+num)
System.out.println (num);
}
while (num <= MAX);
Write an application that counts by three from 3 through 300 inclusive, and that starts a new line after every multiple of 30 (30, 60, 90, and so on).
develop a java console application that either overhaul or automate it.
Implement the following java concept in your solution and highlight in your documentation or code where you did it:
1. Class and Object
2. File and Stream
3. Exception Handling
Martin your friend has declared a class called Employee with the following members; Employee
ID, Employee Name, Basic Salary, Allowance, and Net Salary.
a) Write a code for a member function called get_input that will be used for data input.
(3 Marks)
b) Write a code for a member function called Calculate that will be used to calculate net
salary as the sum of basic salary and allowances.
(2 Marks)
c) Write a code for the default constructor that will assign values to the variables in the
Employee class.
(3 Marks)
d) Write a code for the default constructor.
(3 Marks)
e) Write a complete program that captures and includes all the details in (a-d) above.
Run the code and show your output.