IT 401 Business Computer Languages

profileetrade2016
IT401-Assignment-2-Question-File.docx

Pg. 05

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

( Assignment 2 Deadline: Tuesday 31/10/2017 @ 23:59 [ Total Mark for this Assignment is 30/6=5 ] ) ( Business Computer Languages IT 401 )

( Instructions: 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 . 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 . ) ( Student Details: Name: ### CRN : ### ID: ### )

( 6 Marks ) ( Learning Outcome(s): Instructors: State the Learning Outcome(s) that match this question )Question One

Identify and correct the error(s) in each of the following:

1.double X = 12.5;

int Y =X+4;

2.if (x = 1)

y++;

else if (x = 2)

y = y + 2;

3. final double QUARTER_VALUE = 0.25;

QUARTER_VALUE = 0.30;

( 8 Marks ) ( Learning Outcome(s): Instructors: State the Learning Outcome(s) that match this question )Question Two

2.1Given the code:

what is the output in each of the following cases?

1.x=5 , y=2 , z=2

2.x=2 , y=0 , z=0

3.x=-1 , y=0 , z=0

2.2 what is the output of the following code :

( 9 Marks ) ( Learning Outcome(s): Instructors: State the Learning Outcome(s) that match this question )Question Three

Write complete Java programs, provide a screen snapshot

showing your program in execution to receive full credit.

Write a program that reads a Celsius degree in double from the console, then converts it to Fahrenheit and displays the result.

The formula for the conversion is as follows:

𝐹𝑎ℎ𝑟𝑒𝑛ℎ𝑒𝑖𝑡=(9÷5 )×𝐶𝑒𝑙𝑠𝑖𝑢𝑠+ 32

Typical run of the program:

Enter a Celsius degree: 35.5

35.5 degree Celsius is about 67.5 Fahrenheit.

( 3 Marks ) ( Learning Outcome(s): Instructors: State the Learning Outcome(s) that match this question )Question Four

Write the following mathematical expressions in Java.

https://www.cs.indiana.edu/classes/a201-dger/sum2000/quizzes/images/img3.gif

( 4 Marks ) ( Learning Outcome(s): Instructors: State the Learning Outcome(s) that match this question )Question Five

Consider the code:

String s;

Scannerin = newScanner(System. in );

System. out .print("Enter a word: ");

s = in.next();

5.1 write one statement to test if the user enters the string "Hello".

5.2 assumes = "I love KSA" ;

What is the output the following code ?

String S1= s.substring(4,10);

System. out .println(S1);