Professional Documents
Culture Documents
Practical 18.3
Practical 18.3
Practical 18.3
After click on
Factorial button, second screen will open and it should display factorial of the same number.
Also specify which type of intent you will use in this case.
XML File:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout 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"
tools:context=".MainActivity"
>
<EditText
android:id="@+id/t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="75dp"
android:layout_y="248dp"
android:ems="10"
android:hint="Enter Number:"
android:inputType="text" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="139dp"
android:layout_y="354dp"
android:onClick="Fact"
android:text="Factorial" />
</AbsoluteLayout>
JAVA File:
package com.example.practical183;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
XML File 2:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".MainActivity2">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=""
android:textSize="25dp"
android:textStyle="bold"
tools:layout_editor_absoluteX="149dp"
tools:layout_editor_absoluteY="72dp" />
</LinearLayout>
JAVA File 2:
package com.example.practical183;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
}
}
OUTPUT: