Skip to content

BM-INFINITY/MAD_PR_1

Repository files navigation

Practical-1 develop a Kotlin program for demonstrating various programming concepts.

📌 List of Programs

1.1 Store & Display Values in Different Variables

  • Demonstrates declaring and displaying variables of various data types:
    • Integer, Double, Float, Long, Short, Byte, Char, Boolean, and String.
image

1.2 Type Conversion

  • Converts values between different data types:
    • Integer → Double
    • String → Integer
    • String → Double
image

1.3 Scan Student’s Information & Display

  • Accepts user input for student details such as name, enrolment no, branch, etc.
  • Displays the entered details neatly formatted.
image

1.4 Check Odd or Even Numbers

  • Reads a number and determines whether it is odd or even.
  • Uses control flow directly inside println().
image

1.5 Display Month Name

  • Takes an integer (1–12) as input.
  • Uses a when expression to display the corresponding month name.
image

1.6 User-Defined Function for Arithmetic Operations

  • Implements a function to perform:
    • Addition, Subtraction, Multiplication, Division
  • Accepts two numbers as input and displays results.
image

1.7 Factorial Calculation with Recursion

  • Demonstrates recursion by calculating factorial of a number.
image

1.8 Working with Arrays

  • Explores Kotlin array functions:
    • Arrays.deepToString()
    • contentDeepToString()
    • IntArray.joinToString()
  • Demonstrates loop operations (for, range, downTo, until)
  • Implements sorting:
    • Without built-in functions (manual sorting)
    • With built-in functions (sortedArray())
image

1.9 Find Maximum Number from ArrayList

  • Creates an ArrayList<Int> and finds the maximum value using iteration and built-in functions.
image

1.10 Class and Constructor Creation (Car Example)

  • Defines a Car class with properties:
    • type, model, price, owner, milesDriven
  • Implements functions:
    • Get car information
    • Calculate original price and current price
    • Display formatted details
image image

1.11 Operator Overloading & Matrix Operations

  • Explains operator overloading in Kotlin.
  • Implements a Matrix class with overloaded operators for:
    • Addition (+)
    • Subtraction (-)
    • Multiplication (*)
  • Overrides toString() for customized output formatting.
image

1-1 Swap Value of two variables without using third variable and with using third variable.

image

1-2 Create two class named as Product and Laptop. Inherit with this information: Product class should be parent and child class should be Laptop class.

Add Product Name, Quantity, Amount per Quantity in Product class. In Laptop class add CPU name, RAM size, HDD Size, etc. of Laptop configuration. Create primary and secondary Constructor of both class. If Primary constructor is there then can we create secondary constructor in inheritance? If we can create secondary and primary constructor both in child class then what is restriction if parent have more than two different secondary constructor? Create List of 5 laptops in ArrayList and display all objects information. image image


**1-3 Create two class named as Person and Student. Inherit with this information: Person class should be parent and child class should be Student class. **

Add first name, last name, age in Person class. In Laptop class add enrollment no, branch, class, lab batch, etc. Create primary and secondary Constructor of both class. Create List of 5 students in ArrayList and display all objects information.

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages