You are on page 1of 4

CSCI250L Test 3 SPR2020

Lebanese International University - Tripoli Campus


School of Arts and Sciences - Department of Computer Science

Course Name : Intr. to Programming Course Code : CSCI250L


Date : Section :
Instructor : Time :

Auditorium : Seat Number :

Number of pages : Allowed Time :


Documents : Not Allowed Calculators : Allowed

Problem# Grade Total Grade


Part I
Problem 1 /40
Problem 2 /60

/100

Page 1 of 4
CSCI250L Test 3 SPR 2020

Problem1 :

We want to create a java program to read the grades of 5 students, store it into an array
than display their average and the number of failed and passed students.

Below are the steps:

a) Create the array of grades to store the grade.


b) Store the student grades into grades.
c) Calculate and display the average of grades
d) Display the number of passed and the number of failed students
(Student grade should be >= 12 to pass)
Sample Run:
Please give a grade:
11.5
Please give a grade:
12.5
Please give a grade:
8
Please give a grade:
18
Please give a grade:
15

The average is =13.0

The number of Passed students is = 3


The number of failed students is = 2

Page 2 of 4
CSCI250L Test 3 SPR 2020

Problem2 : [60 pts]:


An online store sells three products which types and prices are displayed in the below table.

Product Type Price ($)


A 2.5
B 4
C 6.5

a- Write a method that takes as parameters the product type and its quantity and returns the
corresponding whole price of product (price = type * quantity).

public static double ProductsPrice(Char type, int quantity)

b- In the main, the user enters three products and the corresponding quantity. At the end, the
program displays the total price (some of the three products prices).

You may use the method to calculate the product Prices.

Sample Run 1:
Enter product type: C
Enter quantity: 2
Product C price = 13 $

Enter product type: B


Enter quantity: 3
Product B price = 12 $

Enter product type: A


Enter quantity: 1
Product A price = 2.5 $

Total due is: $27.5

Good Luck

Page 3 of 4
CSCI250L Test 3 SPR 2020

Page 4 of 4

You might also like