Question One

Write a set of Java statements that represent the following Flowchart using if/else statements. Note: the variable attendance is a boolean variable equals to false.

boolean attendance=false; see image.

Question Two

Identify and correct the error in the following codes, and state what type of error you will get?

A) public class Assignmet2{
public static void main(String []args){
int x=2;
for(int year=1; year>=0; year--)
for (int day=2; day!=3; year++)
{if ( x>=1) System.out.println("Yes");
else System.out.println("No");
x--;} }}
B) int[] grade = new int[20];
for(int counter=0; counter<=grade.length; i++)
grade[counter]=20;

Question Three

Given the following Java statement:

ArrayList< String> grade = new ArrayList< String>();

A)Insert the letter A to the array.

B)Insert the letter B to index 0.

C)Write the Java statement to check the size of the grade list.

D)Remove the letter "A" from the array.

Question Four

Write a set of Java statements that fulfil the following requirements:

  • Print the statement "This is a Loop Number" followed by the iteration number. Your output must match the Figure below.
  • Print the statement "Set of Loops completed" after every 10th iteration.
    • Use the condition counter%10==0 to fulfil this requirement.
    • When the condition is not true print an empty string.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.