Designing a Student Grading Android App: A Step-by-Step Guide

 Introduction:

In this blog post, we will walk through the process of designing an Android application that takes student details and subject marks as input, calculates the student's grade based on the obtained percentage, and displays the result using ViewGroup components.

Step1: Setting Up the Project

Start by creating a new Android Studio project. Choose an appropriate project name and set up the basic configuration. Ensure that you have the latest Android SDK installed.

Step2: Desinging the User Interface (UI):

Write a below code in activity_main.xml file located in res ->layout-> activity_main.xml 

Xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:padding="16dp"
tools:context=".MainActivity"

>
<EditText
android:id="@+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Name"
android:padding="13dp"
/>
<EditText
android:id="@+id/editTextSubj1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Subj1 Marks"
android:padding="13dp"
/>
<EditText
android:id="@+id/editTextSubj2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Subj2 Marks"
android:padding="13dp"
/>
<EditText
android:id="@+id/editTextSubj3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="13dp"
android:hint="Enter Subj3 Marks"
/>
<Button
android:id="@+id/btncalculate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Calculate Grade"/>

<TextView
android:id="@+id/textviewResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>
</LinearLayout>

Note: This layout includes EditText for entering student details and subject marks, a Button for triggering the grade calculation, and a TextView for displaying the result.


Step3: Implementing the Logic

Java code(MainActivity.java) Located in Java -> your package name -> MainActivity.java

Java Code:
package com.app.exam;

import static com.app.exam.R.*;

import androidx.appcompat.app.AppCompatActivity;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;



public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(layout.activity_main);

final EditText editTextname=findViewById(id.editTextName);
final EditText editTextsubject1=findViewById(id.editTextSubj1);
final EditText editTextsubject2=findViewById(id.editTextSubj2);
final EditText editTextsubject3=findViewById(id.editTextSubj3);
final TextView ResultTextView=findViewById(id.textviewResult);
final Button submitbutton=findViewById(id.btncalculate);

submitbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String Name=editTextname.getText().toString();
int subject1 = Integer.parseInt(editTextsubject1.getText().toString());
int subject2=Integer.parseInt(editTextsubject2.getText().toString());
int subject3=Integer.parseInt(editTextsubject3.getText().toString());
double percentage=(subject1+subject2+subject3)/3.0;

String Grade;
if(percentage>=90){
Grade="A";
} else if (percentage<90 && percentage>=75) {
Grade="B";
} else if (percentage<75 && percentage>=50) {
Grade="C";

}
else {
Grade="fail";
}

String result="Name:"+Name+"\nPercentage :"+ percentage +" \nGrade "+ Grade;
ResultTextView.setText(result);
}
});
}
}

OUTPUT:

Output Screen of App















































For Download Android Studio for Application Devlopment Visit on :

Comments