0% found this document useful (0 votes)
579 views3 pages

CS SemisV2

This document contains instructions for a semi-final examination on advanced computer programming. It provides 24 programming tasks to be completed, covering topics like methods, classes, generics, and fractions. It also lists the vision and mission of Batangas State University in the Philippines where the exam is being administered. Validation of input data is required for some problems. Classes are to be defined for mobile phones, batteries, displays, calls, libraries, schools, and generic lists. Testing classes are also to be written. The document was prepared by an instructor, reviewed by an associate dean, and approved by a dean.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
579 views3 pages

CS SemisV2

This document contains instructions for a semi-final examination on advanced computer programming. It provides 24 programming tasks to be completed, covering topics like methods, classes, generics, and fractions. It also lists the vision and mission of Batangas State University in the Philippines where the exam is being administered. Validation of input data is required for some problems. Classes are to be defined for mobile phones, batteries, displays, calls, libraries, schools, and generic lists. Testing classes are also to be written. The document was prepared by an instructor, reviewed by an associate dean, and approved by a dean.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Republic of the Philippines

BATANGAS STATE UNIVERSITY LIPA CITY


Marawoy, Lipa City, Philippines 4217
COLLEGE OF ENGINEERING AND COMPUTING SCIENCES
Tel. No. (043) 404-7619/(043) 980-0387

Semi-Final Examination
Advanced Computer Programming
Second Semester, AY 2018 – 2019

Name: __________________________________________ Score: ___________


Section: _________________________________________ Date: ___________
VISION
A globally recognized institution of higher learning that develops competent and morally upright citizens who are active
participants in nation building and responsive to the challenges of 21st century.
MISSION
Batangas State University is committed to the holistic development of productive citizens by providing a conducive learning
environment for the generation, dissemination and utilization of knowledge through innovative education, multidisciplinary research
collaborations, and community partnership that would nurture the spirit of nationhood and help fuel national economy for sustainable
development.

I. Application

Methods:

1. Write a method that calculates the sum of two polynomials with integer coefficients,
for example (3x2 + x - 3) + (x - 1) = (3x2 + 2x - 4).
2. Write a program that calculates and prints the n! for any n in the range [1…100]
3. Write a method that finds the biggest element of an array. Use that method to
implement sorting in ascending order.
4. Write a program that solves the following tasks:
- Put the digits from an integer number into a reversed order.
- Calculate the average of given sequence of numbers.
- Solve the linear equation a * x + b = 0.
Create appropriate methods for each of the above tasks.
Make the program show a text menu to the user. By choosing an option of that menu,
the user will be able to choose which task to be invoked. Make a list of six daily
activities you perform. They might include preparing homework assignments,
shopping, and other activities. Ensure that three of the activities call for decision
making that is unstructured (or semistructured) and that three involve structured
decision making. Prepare a one-page report listing the activities, stating what decision

Perform validation of the input data:


- The integer number must be a positive in the range [1…50,000,000].
- The sequence of numbers cannot be empty.
- The coefficient a must be non-zero.

Classes:

Phone Information

5. Define a class, which contains information about a mobile phone: model,


manufacturer, price, owner, features of the battery (model, idle time and hours talk)
and features of the screen (size and colors).
6. Declare several constructors for each of the classes created by the previous task,
which have different lists of parameters (for complete information about a student or
part of it). Data fields that are unknown have to be initialized respectively with null
or 0.
7. To the class of mobile phone in the previous two tasks, add a static field nokiaN95,
which stores information about mobile phone model Nokia N95. Add a method to the
same class, which displays information about this static field.
8. Add an enumeration BatteryType, which contains the values for type of the battery
(Li-Ion, NiMH, NiCd, …) and use it as a new field for the class Battery.
9. Add a method to the class GSM, which returns information about the object as a
string.
10. Define properties to encapsulate the data in classes GSM, Battery and Display.
11. Write a class GSMTest, which has to test the functionality of class GSM. Create
few objects of the class and store them into an array. Display information about the
created objects. Display information about the static field nokiaN95.
12. Create a class Call, which contains information about a call made via mobile phone.
It should contain information about date, time of start and duration of the call.
13. Add a property for keeping a call history – CallHistory, which holds a list of call
records.
14. In GSM class add methods for adding and deleting calls (Call) in the archive of
mobile phone calls. Add method, which deletes all calls from the archive
15. In GSM class, add a method that calculates the total amount of calls (Call) from the
archive of phone calls (CallHistory), as the price of a phone call is passed as a
parameter to the method.
16. Create a class GSMCallHistoryTest, with which to test the functionality of the class
GSM, from task 9, as an object of type GSM. Then add to it a few phone calls (Call).
Display information about each phone call. Assuming that the price per minute is
0.37, calculate and display the total cost of all calls. Remove the longest conversation
from archive with phone calls and calculate the total price for all calls again. Finally,
clear the archive

Book Library

17. There is a book library. Define classes respectively for a book and a library. The
library must contain a name and a list of books. The books must contain the title,
author, publisher, release date and ISBN-number. In the class, which describes the
library, create methods to add a book to the library, to search for a book by a
predefined author, to display information about a book and to delete a book from the
library
18. Write a test class, which creates an object of type library, adds several books to it and
displays information about each of them. Implement a test functionality, which finds
all books authored by Stephen King and deletes them. Finally, display information for
each of the remaining books
19. We have a school. In school we have classes and students. Each class has a number of
teachers. Each teacher has a variety of disciplines taught. Students have a name and a
unique number in the class. Classes have a unique text identifier. Disciplines have a
name, number of lessons and number of exercises. The task is to shape a school with
C# classes. You have to define classes with their fields, properties, methods and
constructors. Also define a test class, which demonstrates, that the other classes work
correctly
20. Write a generic class GenericList<T>, which holds a list of elements of type T. Store
the list of elements into an array with a limited capacity that is passed as a parameter
of the constructor of the class. Add methods to add an item, to access an item by
index, to remove an item by index, to insert an item at given position, to clear the list,
to search for an item by value and to override the method ToString()
21. Implement auto-resizing functionality of the array from the previous task, when by
adding an element, it reaches the capacity of the array.
22. Define a class Fraction, which contains information about the rational fraction (e.g. ¼
or ½). Define a static method Parse() to create a fraction from a sting (for example
-3/4). Define the appropriate properties and constructors of the class. Also write
property of type Decimal to return the decimal value of the fraction (e.g. 0.25).
23. properties and constructors of the class. Also write property of type Decimal to return
the decimal value of the fraction (e.g. 0.25).
24. Write a function to cancel a fraction (e.g. if numerator and denominator are
respectively 10 and 15, fraction to be cancelled to 2/3).

Prepared by:

Mr. DIONECES ALIMOREN


Instructor
Date:

Reviewed by:

Dr. MICHAEL C. GODOY


Associate Dean
Date:

Approved by:

Dr. NERRIE E. MALALUAN


Dean of Colleges
Date:

You might also like