Android Studio

Student Marks Calculation App in Android Studio

This tutorial will teach you Student Marks Calculation Project in Android Studio step by step.
Input Student Name, Marks and Calculate the Total,avg,grade.when you calculate the grade you have to follow the Following Conditions.if the avg is greater than 50 grade will be pass other wise grade will be fail.

Design the UI Design

Android studio folder structure there is folder which is res this is the folder will help us to make a UI Design of the App.inside res folder you can see the layout folder if you expand the layout folder there is a file
activity_main.xml
in this file we will design App Layout i have design the registration UI design below.

activity_main.xml

<?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=".MainActivity"
    android:orientation="vertical"
    android:gravity="center">

    <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
     android:gravity="center">

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
         android:gravity="center">

          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="30sp"
              android:gravity="center"
              android:text="@string/emptitle"
              android:textSize="15dp"
              android:textStyle="bold"
              android:textColor="@color/colorPrimary"
              />

         <ImageView
             android:layout_width="200sp"
             android:layout_height="100sp"
             android:gravity="center"
             android:src="@drawable/marks"
             />
         </LinearLayout>


     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="center"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20sp"
             android:text="@string/stname"
             android:textSize="15sp"
             android:textStyle="italic"
             android:textColor="@color/colorAccent"

             />

         <EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:id="@+id/stname"
             android:textColor="@color/colorPrimary"
             android:gravity="center"
             />

     </LinearLayout>

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="center"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="15sp"
             android:text="@string/marks1"
             android:textSize="15sp"
             android:textStyle="italic"
             android:textColor="@color/colorAccent"

             />

         <EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:id="@+id/mark1"
             android:textColor="@color/colorPrimary"
             android:gravity="center"

             />

     </LinearLayout>

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="center"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="15sp"
             android:text="@string/marks2"
             android:textSize="15sp"
             android:textStyle="italic"
             android:textColor="@color/colorAccent"

             />

         <EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:id="@+id/mark2"
             android:textColor="@color/colorPrimary"
             android:gravity="center"

             />

     </LinearLayout>


     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="center"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20sp"
             android:text="@string/marks3"
             android:textSize="15sp"
             android:textStyle="italic"
             android:textColor="@color/colorAccent"

             />

         <EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:id="@+id/mark3"
             android:textColor="@color/colorPrimary"
             android:gravity="center"

             />

     </LinearLayout>

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="center"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20sp"
             android:text="@string/total"
             android:textSize="15sp"
             android:textStyle="italic"
             android:textColor="@color/colorAccent"

             />

         <EditText
             android:id="@+id/total"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:gravity="center"
             android:textColor="@color/colorPrimary"

             />

     </LinearLayout>

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="center"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20sp"
             android:text="@string/avg"
             android:textSize="15sp"
             android:textStyle="italic"
             android:textColor="@color/colorAccent"

             />

         <EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:id="@+id/avg"
             android:textColor="@color/colorPrimary"
             android:gravity="center"

             />

     </LinearLayout>


     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="center"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="20sp"
             android:text="@string/grade"
             android:textSize="15sp"
             android:textStyle="italic"
             android:textColor="@color/colorAccent"

             />

         <EditText
             android:id="@+id/grade"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:gravity="center"
             android:textColor="@color/colorPrimary"

             />

     </LinearLayout>



     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:gravity="right"
         >


         <Button
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/btnok"
             android:textColor="#ffffff"
             android:background="@color/colorPrimary"
             android:id="@+id/btn1"

             />


         <Button
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/btnclear"
             android:textColor="#ffffff"
             android:background="@color/colorAccent"
             android:id="@+id/btn2"
             />
     </LinearLayout>
 </LinearLayout>



</LinearLayout>

Inside the Value Folder we have to Make the App Style.

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#008577</color>
    <color name="colorPrimaryDark">#00574B</color>
    <color name="colorAccent">#D81B60</color>
</resources>

strings.xml

<resources>
    <string name="app_name">Student Marks Calculation System</string>
    <string name="emptitle">Student Marks Calculation System</string>
    <string name="stname">Student Name</string>
    <string name="marks1">Marks 1</string>
    <string name="marks2">Marks 2</string>
    <string name="marks3">Marks 3</string>

    <string name="total">Total</string>
    <string name="avg">Average</string>
    <string name="grade">Grade</string>


    <string name="btnok">Ok</string>
    <string name="btnclear">Clear</string>
</resources>

style.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

MainActitity.java

package com.example.kobinath.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    EditText ed1,ed2,ed3,ed4,ed5,ed6,ed7;
    Button btn1,btn2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ed1 = findViewById(R.id.stname);
        ed2 = findViewById(R.id.mark1);
        ed3 = findViewById(R.id.mark2);
        ed4 = findViewById(R.id.mark3);
        ed5 = findViewById(R.id.total);
        ed6 = findViewById(R.id.avg);
        ed7 = findViewById(R.id.grade);


        btn1 = findViewById(R.id.btn1);
        btn2 = findViewById(R.id.btn2);


        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                stmarks();
            }

        });

        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clear();
            }
        });

    }


    public void stmarks()
    {

           int m1,m2,m3,tot;
          double avg;
          String grade;
            m1 = Integer.parseInt(ed2.getText().toString());
            m2 = Integer.parseInt(ed3.getText().toString());
            m3 = Integer.parseInt(ed4.getText().toString());

            tot = m1 + m2 + m3;
            ed5.setText(String.valueOf(tot));
            avg = tot/3;
             ed6.setText(String.valueOf(avg));

               if(avg > 75)
               {
                 ed7.setText("A");
                }
               else if(avg > 65)
                {
                    ed7.setText("B");
                }

                else if(avg > 55)
                {
                       ed7.setText("C");
                }


                 else if(avg > 40)
                  {
                         ed7.setText("S");
                  }

                 else
               {
                       ed7.setText("Fail");
               }
    }

    public void clear()
    {
          ed1.setText("");
          ed2.setText("");
          ed3.setText("");
          ed4.setText("");
          ed5.setText("");
          ed6.setText("");
          ed7.setText("");

        ed1.requestFocus();

    }
}

I have attached the video tutorial below it will help you  to do this  step by step.

admin

Recent Posts

Fish Inventory Shop Management System in Angular

This article explain how to make a Fish Inventory Management App in Angular.this app explain…

5 days ago

Fish Inventory Management with React

Introduction to Fish Inventory Management In the aquaculture industry, managing fish inventory is crucial for…

6 days ago

Java GUI CRUD for Beginners

Introduction to Java GUI CRUD Java is a powerful programming language widely used for building…

6 days ago

Creating Beautiful Login Form Design Using React

Introduction to Login Form Design Designing an effective and beautiful login form is crucial for…

2 weeks ago

Creating Responsive Login Form with React

Introduction In today creating a responsive login form is essential for providing a seamless user…

2 weeks ago

Master React Inventory Management System Development

Introduction to Inventory Management Systems In today's fast-paced digital environment, businesses require efficient inventory management…

2 weeks ago