Wireless Programming Spring 2021 answer Android Source Code [DIU]

Do you know the secrete of your student id? Your student id has some inner meaning. For example, one student having this student id (182-15-12345). Every number separated by the hyphen (-) has some special meaning. Let me explain you one by one. The first portion contains 182. The first two digits (18) indicates in which year a student has admitted and the last digit (2) indicates the semester. So, 182 means a student has admitted into DIU in summer 2018. Now come to the second portion, which contains 15. This is the code of the department of CSE. Every department in DIU has a unique department code. Moreover, the last portion contains 12345, is the student number of that student. Department Codes and Semester mapping are given below. Now your job is to design an android application which will contain two activities named StartActivity and InfoActivity. In the StartActivity, you will have three EditText
components and a button. First EditText component will suggest entering your Name, the second one will suggest entering your student id (as string), and the third one will suggest you to entering your mobile number (as string). The button will be named as the “Go to Next” button. If you press the “Go to Next” button, you will be moved to the InfoActivity. Before going to the InfoActivity, it will pass your name, student id, and mobile number from the EditText
components. The InfoActivity will contain one button named “Process Info” button and a TextView. After pressing the Process Info button, it will do some work in the background with the data it received from the StartActivity and show some text in the TextView. It will analyze the mobile number that has received from the StartActivity. Based on the last digit of the mobile number it will analyze the student id and show a message in the TextView. Samples are given
below.

No description available.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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:layout_margin="15dp"
    tools:context=".StartActivity">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Full Name"
        android:layout_marginBottom="18dp"
        android:layout_above="@+id/stId"
        android:id="@+id/fullName"/>

    <EditText
        android:maxLines="1"
        android:id="@+id/stId"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Student Id (183-15-11820)"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"/>
    <EditText
        android:layout_marginTop="18dp"
        android:layout_below="@+id/stId"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Phone Number"
        android:maxLength="11"
        android:autoSizeTextType="none"
        android:maxLines="1"
        android:id="@+id/phnNumber"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Go to Next"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:onClick="gotoInfoActivity"
        android:layout_marginBottom="20dp"/>


</RelativeLayout>
package com.techzweb.midpractise;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class StartActivity extends AppCompatActivity {

    String stId,stName,stPhn;
    EditText stIdEt,stNameEt,stPhnEt;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().setTitle("Start Activity");
        setContentView(R.layout.activity_start);
        stIdEt= findViewById(R.id.stId);
        stNameEt= findViewById(R.id.fullName);
        stPhnEt= findViewById(R.id.phnNumber);
    }

    public void gotoInfoActivity(View view) {
        stId = stIdEt.getText().toString();
        stName = stNameEt.getText().toString();
        stPhn = stPhnEt.getText().toString();
        if(stId.length()<11 && !stId.contains("-1")){
            Toast.makeText(StartActivity.this,"Student Id Error !",Toast.LENGTH_LONG).show();
        }else if(stName.isEmpty()){
            Toast.makeText(StartActivity.this,"Student Name Empty !",Toast.LENGTH_LONG).show();
        }else if(stPhn.length()!=11){
            Toast.makeText(StartActivity.this,"Phone Number Will 11 digit !",Toast.LENGTH_LONG).show();
        }else {
            Intent intent = new Intent(StartActivity.this,InfoActivity.class);
            intent.putExtra("id",stId);
            intent.putExtra("name",stName);
            intent.putExtra("phone",stPhn);
            startActivity(intent);
        }

    }
}
No description available.
No description available.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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:layout_margin="15dp"
    tools:context=".InfoActivity">
    <TextView
        android:textSize="20sp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:id="@+id/infoTxt"/>
    <TextView
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_marginTop="20dp"
        android:layout_below="@+id/infoTxt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:id="@+id/desc"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/processInfo"
        android:text="Process Info"
        android:layout_alignParentBottom="true"
        android:onClick="processInfo"
        android:layout_marginBottom="20dp"
        android:layout_centerHorizontal="true"/>


</RelativeLayout>
package com.techzweb.midpractise;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class InfoActivity extends AppCompatActivity {

    String id,phone,name;
    TextView info,desc;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().setTitle("Info Activity");
        setContentView(R.layout.activity_info);

        info= findViewById(R.id.infoTxt);
        desc = findViewById(R.id.desc);
        Bundle bundle = getIntent().getExtras();
        if(bundle.getString("name")!=null && bundle.getString("id")!=null && bundle.getString("phone")!=null)
        {
            id=bundle.getString("id");
            phone= bundle.getString("phone");
            name = bundle.getString("name");
            info.setText("Student Name : "+name+"\nStudent ID : "+id+"\nPhone Number : "+phone);
        }
    }

    public void processInfo(View view) {
//        Hasan has admitted in
//        Software Engineering
//        Department.
        String department,smstr;



       if(phone.charAt(10)% 2 == 0){
           if(id.charAt(2)=='1'){
               smstr = " Spring ";
           }else if(id.charAt(2)=='2')
           {
               smstr = " Summer ";
           }else if(id.charAt(2)=='3')
           {
               smstr = " Fall ";
           }else {
               smstr = " Not Found ";
           }
           desc.setText(name+" has admitted in"+smstr+"20"+id.charAt(0)+id.charAt(1));
       }else {
           if(id.contains("-15-")){
               department = " CSE ";
           }else  if(id.contains("-14-")){
               department = " Software Engineering ";
           }else  if(id.contains("-13-")){
               department = " BBA ";
           }else  if(id.contains("-12-")){
               department = " English ";
           }else  if(id.contains("-11-")){
               department = " Pharmacy ";
           }else {
               department = "Not Found";
           }

           desc.setText(name+" has admitted in"+department+"Department.");
       }


    }
}
Posted in Education