CS SemisV2
CS SemisV2
Semi-Final Examination
Advanced Computer Programming
Second Semester, AY 2018 – 2019
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
Classes:
Phone Information
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:
Reviewed by:
Approved by: