computer basic Q

profileete08
CS140Assignment1.docx

Pg. 05

خطأ! استخدم علامة التبويب "الصفحة الرئيسية" لتطبيق Heading 1 على النص الذي ترغب في أن يظهر هنا.

Assignment 1

Deadline: Saturday 29/9/2019 @23:59

[Total Mark for this Assignment is 5]

Computer Programming I

CS140

College of Computing and Informatics

Question One

Marks: 3

Learning Outcome(s):

LO4: Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures and arrays.

Create a java program for Student profile with the following requirements.

a) Each Student has: two variables id , and name.

b) A Student can be initialization with two constructers:

· Constructer without parameters, that set the id to zero and the name to an empty string.

· Constructer with tow parameters to initialize the variables id and name by a specific value.

c) Add a set method for each variable that change them to a specific value.

d) Add a get method for each variable which return its value.

To test the program, create a class StudentTest with the main method.

In the main method:

a) Create two empty Student profiles S1 and S2 .

b) Print the S1 and S2 information.

c) Create a new student profile S3 , specify the student id and name .

d) Change S3 id and name.

e) Print the id and name of S3.

Answer:

Question Two

Marks 1

Learning Outcome(s):

Learning Outcome(s):

LO1: Explain the basic principles of programming, concept of language. Universal constructs of programming languages.

For each of the code fragment or declarations in the first column, please state whether the code fragment is correct or incorrect. In case it is incorrect, please provide the correct code in the appropriate cell.

Code fragment

Correct or Incorrect ?

If incorrect, rewrite the correct code

char x=A

int z = 20,000;

double weight = “65”;

public class Count

{

public Count()

{

// body--filled in here

}

// body--filled in here

}

long 1student=123456;

boolean static = true;

Import java.String.Rectangle

public int void deposit(double amount)

{ . . . }

Question Three

Marks 1

Learning Outcome(s):

LO2: Design algorithms using pseudo-code, flowcharts, and structured charts.

A. Write an algorithm in pseudocode to convert temperature from Fahrenheit to Celsius?

Answer:

B. Give an example for compile-time and run-time errors?

Answer:

Compile-Time Errors: are errors that occur when you violate the rules of writing syntax

For example:

1- Missing Parenthesis (})

2- Printing the value of variable without declaring it

3- Missing semicolon (terminator)

Run-Time Errors: are errors which occur during program execution (run-time) after successful compilation.

For example

int n = 9, div = 0;

warning: division by zero [-Wdiv-by-zero]

div = n/0;

Please Attempt the below question. The word limit should be 350 to 400 words for the question.

Q.1. Explain why the communication message that is sent may not be the message that is received between the agents?

References: