National Institute of Technology Rourkela

राष्ट्रीय प्रौद्योगिकी संस्थान राउरकेला

ଜାତୀୟ ପ୍ରଯୁକ୍ତି ପ୍ରତିଷ୍ଠାନ ରାଉରକେଲା

An Institute of National Importance

Syllabus

Course Details

Subject {L-T-P / C} : CS3174 : Advanced Programming Laboratory { 0-0-3 / 2}

Subject Nature : Practical

Coordinator : Prof. Durga Prasad Mohapatra

Syllabus

1. WAP to convert a decimal number to its binary equivalent.
2. WAP to swap two variables without using a third a variable and with using a third variable.
3. WAP to enter a number. Print the last prime number which is smaller than the number.
4. WAP to check whether the entered number is Armstrong or not.
5. Create three functions named 'volume'. First function should compute the volume of a cube taking a double value as argument. Second function should compute the volume of a cylinder taking two double values as parameters. Third function should compute the volume of a rectangular box taking three double values as parameters. Write a program to implement it.
6. Write a program using the concept of function overloading to find the multiplication of two integers and two float values.
7. Write a function named 'power()' to raise a number m to a number n. The function takes a double value for m and an int value for n and returns the result correctly. Use the default value of 2 for n to make the function to calculate squares when this argument is omitted. Write a main() in C++ that gets the values of m and n from the user to test the function.
8. Write a program in using the concept of inline function to perform addition, subtraction, multiplication and division of two double values.
9. Define a class Car. Add Make, Colour, Size, and Cost as data members. Write member functions for reading and printing the values of the car. Define one more class as CarCollection. This class should contain the member functions Add(), Delete(), Modify(), and Replace(). CarCollection is to be defined as friend of Car class. Provide a friend function Replace(), which replaces the content of a Car object with another Car object.
10. Define a class Complex. Write a program in to read a complex number, to write a complex number, to add two complex numbers, to subtract from one complex number to another, to multiply two complex numbers, to divide two complex numbers.
11. Create two classes XYZ and ABC. Each class contains a single data member of integer type. Create a function Compare that is friend to both the classes. The Compare function should compare the data members of the both the classes and displays the greatest one. Write a C++ program to accomplish this.
12. Write a program to swap two objects using friend function.
13. Create a class Complex containing two float data members for real and imaginary part. Write a program to overload – (unary minus), + (addition), - (subtraction), * (multiplication), / (division) operators using friend function.
14. WAP to create a Date class, increment the day, month, year of the Date class using operator overloading mechanism.
15. WAP to create a class MAT of size m x n and define all possible matrix operations for MAT type objects (operator overloading using friend function).

16. Create a class Integer containing an integer data member. Write a program in C++ to overload – (unary minus), + (addition), - (subtraction), * (multiplication), / (division), ++ (pre and post version), (pre and post version), < (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to), == (equal to), != (not equal to) operators.
17. Create a class Complex containing two float data members for real and imaginary part. Write a program to overload – (unary minus), + (addition), - (subtraction), * (multiplication), / (division), ++ (pre and post version), (pre and post version) operators. Pre version should be used for real part and post version should be used for imaginary part.
18. Create a class Time containing three integer data members for hour, minute and second. Write a program to overload + (addition), - (subtraction) operators.
19. Create a class Point containing two float data members for x and y coordinates. Write a program to overload – (subtraction), + (addition) operators.
20. Write a generic program (using templates) to perform all arithmetic operations on two complex numbers where real part and imaginary part are integers and float numbers.
21. Implement the following problem in Java.

• Create a class Clock with the following attributes: Hour (int 1…12), Minutes (int 0…59), Seconds (int 0…59), isAM (Boolean). Class Clock will support the methods: getHours, getMinutes, getSeconds, and getIsAM. Create three constructors: one with no parameters (set clock to midnight), one with hour and isAM specified (sets minutes and seconds to zero), one with all attributes specified. Class Clock also supports a setTime () method that sets all four attributes from argument values and a tick () method that increments time by one second. Instantiate Clock in main, test the clock’s transition from hour to hour, minute to minute, AM to PM.

? Create an interface called SecondObserver that defines a single method tick (). Make class Clock implement this interface.
? Create a new class PrintClock that extends the Clock class. Provide a method that produces the current time. Test the class.
? Create a new class TickingPrintClock that extends PrintClock class. TickingPrintClock extends the tick () method to print the new time on each tick, in addition to the function of the method. Test the class.

Course Objectives

  • To learn the evolution of different programming paradigms, introduction to advanced programming languages such as C++. Java etc.
  • To learn the data types, variables, arrays, operators, control statements, classes, constructors, destructors, overloading methods, inheritance etc.
  • To learn advanced concepts of C++/Java such as, File handling, Applets, Swings, Servlets, etc.
  • To develop programs in advanced programming languages such as C++. Java etc.

Course Outcomes

After reading this subject, students will be able to: <br />1. Understand the evolution of difference programming paradigms, basics of Object-Oriented programming languages. <br />2. Understand and apply data types, variables, arrays, operators, control statements, classes, constructors, destructors, overloading methods, inheritance etc., while developing Object-Oriented programs. <br />3. Use file handling techniques, and I/O concepts, Applets, Swing, Servlets, etc. <br />4. Write programs in advanced programming languages such as C++/Java etc.

Essential Reading

  • H. Schildt, Java: The Complete Reference, Mc-Graw Hill , 2017
  • E. Balagurusamy, Programming with Java: A Primer, Mc-Graw Hill , 2014

Supplementary Reading

  • E. Balagurusamy, Programming in C#: A Primer, McGraw Hill , 2008
  • J. M. Slack, Programming and Problem Solving with JAVA, Thomson/Brooks Core Publishing Company , 2017