BSc(IT) Semester-5
503-Mobile Application Development with Kotlin
Practical Assignment-2
- Develop a kotlin program for class Employee with properties: code, name,
designation , date of birth as DOB, date of joining as DOJ, basic salary, hra, da, dept.
[Calculate da and hra accordingly:
(1)If basic salary is less than 30000 then da=60%, hra=20%
(2)If basic salary more than 30000 and less than 45000 then da=70%,
hra=30%
(3) If basic salary more than 45000 then da=85%, hra=40%]
The behavior of Employee should include:
a. Accept the input from the user.
b. Display the data.
c. To calculate Total salary.
d. To search for the employees who work in ‘Sales’ Dept.
e. Calculate the total experience of employees.
f. Search the employees who have experience more than 5 years. -
- Develop a kotlin program for class student with properties: rollno, name, marks of
3 subjects, total, percentage and grade.
The behavior of student should include:
a. Accept the input from the user.
b. Display the data.
c. Calculate the total marks obtained, percentage and grade of each student.
d. Display the student who secured 1st rank.
- Develop a kotlin program for class student with properties: rollno, name, marks of
----------------2-----------------
//Design
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtRollno"
android:hint="Enter roll no"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtName"
android:hint="Enter name"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtSubject1"
android:hint="Enter marks of first subject"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtSubject2"
android:hint="Enter marks of second subject"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtSubject3"
android:hint="Enter marks of third subject"
/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnAdd"
android:layout_weight="1"
android:text="Add"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnCalculate"
android:layout_weight="1"
android:text="Process"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtDisplay"
android:textSize="60px"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>
//Kotlin
package com.example.a2q2
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val studentList = ArrayList<student>()
val iRollno = findViewById(R.id.edtRollno) as EditText
val stName = findViewById(R.id.edtName) as EditText
val iMark1 = findViewById(R.id.edtSubject1) as EditText
val iMark2 = findViewById(R.id.edtSubject2) as EditText
val iMark3 = findViewById(R.id.edtSubject3) as EditText
val btnProcess = findViewById(R.id.btnCalculate) as Button
val btnAdd = findViewById(R.id.btnAdd) as Button
val stDisplay = findViewById(R.id.txtDisplay) as TextView