We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
—_—=_0L—
oC Try
DEPARTMENT OF come FINEERING
FACULTY OF TN ERING
UNIVERSITY OF BENIN, B) IN Crry, EDO STATE. —
SECOND SEMESTE!
COURSE CODE: CPE 322 (CO!
1 EXAMIN
‘ATION (2922/2023 SESSION)
/MMERCIAL PROGTAMMING LANGUAGES) TIME: 2 HOURS: 30
jinutes
INSTRUCTION: ANSWER ANY Foup QUESTIONS
SECTION A 4" Programming)
TPO ove UE SCAANET
public class Main ¢
public static void main (String 0)
args) {
Scanner myObj = new
scahnee(System.in)i
system.out printin("enter X1:");
int X1 = myObj.nextint();
gystem.out.printin(“Enter Yi";
jnt Y= myObj.nextint();
‘System out printin( enter 22");
int ¥2 = myObj.nextint():
int deitax = X2 - X47
int deltaY = Y2 - Yi
double distance =
~ Math.sart(deltax * deltax + deltaY ~
deltaY);
system.out.
between the point:
intin("Distance
"+ distance);
myObj.close();
system.out.printin(“Enter x20) ,
Sint X2 = myObj-nextint();, x ‘ “, \
e ; Dull ndle yet! CP,
Figure 1
QL x 4 =
‘n° Clearly comment on each line of code in the programs listed in Figure 1 (10 marks)
b. Summarize what the programs ig trying to achieve in simple sentences (5 marks)
¢. Why is the while loop referred to as @ Prt tested loop? (1 mark)
4. Rewrite the program to accept inputs in decimal format (4 marks)
Q2.
ii. Calculate Force (formula: F =m * a)
«With the use of methods in the Java programming language,
2 Caleulate Kinetic Energy (formula: E= 4m)
develop each of the following programs:
ii, Calculate Current (V=IXR) = : (15 marks)
iv. What is the use of a compiler as regards programming languages? (2 marks)
y.Make clear distinctions among High evel, assembly and low-level languages G3 marks)
@. Mall. gue
a. Code either a method or a user entry only in the Java programming language (0:
i. Calculate the sum of three numbers = (4 marks)
Convert radian to degrees | (6 marks)
Find the perimeter of a triangle (5 marks)
'b. What isthe importance of the JVM in J3¥ programing? Give an example (2 marks)
jaclude *dequate comments to earn full marks! |
Note://In all programsSECTION 8 (Sharp Programming)
Write a C# Sharp program to read age
his/her own vote...
da,
oe Ht
fa candidate and determine whether it is eligible for casting
SMARKS
, C1 . ling to
RG, an a C# Sharp program to accept q Person's height in centimeters and categorize them oe
€ Write a C program to find the largest of three numbers. 4MARKS \
G Write a C# Sharp program to read ‘smperature in centigrade and display a suitable message according to
the temperature state below:
‘Temp < 0 then Freezing weather
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
‘Temp 20-30 then Normal in Temp ~ = ‘i L ss
‘Temp 30-40 then Its Hot ia
Temp>=40 then Its Very Hot 7MARKS
5a. Write a program that accepts two numbers and an operator as input to performs a simple calculator task
Prt, aie 4MARKS
b Write C# Sharp program to read any Month Number i
in integer and display Month name SMARKS .
¢ Write a C# Sharp program to check whether a triangle is Equilateral, Isosceles or Scalene, 4MARKS
4 Write a C# Sharp program to determine the ligibili
the following criteria: :
Marks in Maths >:
Marks in Phy
Marks in Chem>:
y
Total in Math and Subjects
TMARKS
6a, Briefly describe the terms array
on how they are declared?
sional arrays, Jagged Arrays, and state example for each .
6MARKS
b With a Flow Chart, Write a C# Sharp Program to access the elements in the array using the index of the
array - {1,2,3} " 4MARKS
& Using the array operations, write a C# Sharp program to find minimum and maxirnum elements inj
the given set of numbers {51, 1, 3, 4, 98}. (4 smarks'
d Write a Ci# Sharp program that stores elements in an array and prints output. SMARKS *|
Note://In all programs, include adequate comments to enrn full marks! :
Course Lectur*
System outprintin ("Dr A.I. Edeoghon, Engr. MO. Omosig*
1o3t