Question: This Assignment must be submitted on Blackboard via the allocated folder. Email submission will not be accepted. You are advised to make your work clear

This Assignment must be submitted on Blackboard via the allocated folder.

Email submission will not be accepted.

You are advised to make your work clear and well-presented, marks may be reduced for poor presentation.

You MUST show all your work.

Learning Outcome(s):

Become familiar with implementation of classes, and objects

2 Marks

Learning Outcome(s):

Become familiar with implementation of classes, and objects

Question One

When running JavaApplication8, the following output is seen on the display:

Addition(2,3) = 5

JavaApplication.java is given below with some missing parts in the Circuit class and printCircuit method (missing parts are identified by dots):

class Circuit{

private String operation;

private int number1, number2, output;

public Circuit(int n1, int n2){ }

public void setNumbers(int n1, int n2){ }

public void setOperation(){operation=op;}

public void setN1(int n){number1 = n;}

public void setN2(int n){number2 = n;}

public void setOutput(int n){ = n;}

public getOperation(){return operation;}

public getN1(){return number1;}

public int getN2(){}

public int getOutput(){return output;}

}

public class JavaApplication8 {

private static void printCircuit(Circuit a) { }

public static void main(String[] args) {

Circuit a1 = new Circuit(2,3);

a1.setOperation("Addition");

a1.setOutput(a1.getN1()+a1.getN2());

printCircuit(a1);

}

}

1. Fill in all missing parts

2. Modify the main() method so that the output becomes:

Subtraction(2,3) = -1

0.5 Marks

Learning Outcome(s):

Design algorithms using pseudo-code

Question Two

What is Pseudo-code? Write a Pseudo-code to determine a students final grade and indicate whether it is passing or failing. The final grade is calculated as the average of five marks. (Passing criteria is Grade >=50 )

0.5 Marks

Learning Outcome(s):

Introduction to programming

Question Three

What is the use of class file in Java Programming?

0.5 Marks

Learning Outcome(s):

Write, compile and run complete Java program

Question Four

Write a complete java program that will display the word CS and the number 140, each on its own line.

1 Marks

Learning Outcome(s):

Distinguish between valid/invalid identifiers and the Java keywords

Question Five

Which of the following identifiers are valid? Which are Java keywords?

miles, Test, a++, 4#R, $4, #44, apps

class, int, x

0.5 Marks

Learning Outcome(s):

Identify and fixing the errors in Java program

Question Six

Identify and fix the errors in the following Java program

public class Test { public static void main(String[] args) { int i = k + 2; System.out.println(i); } }

Late submission will result in ZERO marks being awarded.

The work should be your own, copying from students or other resources will result in ZERO marks.

Use Times New Roman font for all your answers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!