Business Computer Languages/Computer Science

Business Computer Languages/Computer Science

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 questionQuestion 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 questionQuestion 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 questionQuestion 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 questionQuestion 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 questionQuestion 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);

Order from us and get better grades. We are the service you have been looking for.