Christine Cloma

Android – Semester Grade App

Create an android project for the following problem.

You are tasked to create an Android project that will compute for the Semestral Grade for students. The following are the requirements of the said project; Student Id Number, Name of Student, Course, Year Level, Assignment (10%), Quizzes (40%), Recitation (10%) and Exam (40%). Compute the grade by adding the assignment, quizzes, recitation and exams.

View1

As you can see the photo above, the user can input the first requirements such as ID Number, Name of student, Course, Year level. The second one is for Assignments, Quizzes, Recitation and Exams. The first EditText (left side) indicates the SCORE of the student which is divided by the TOTAL number of the said requirement. (right side).

Once you completed to filed up. Click the “Compute” button for the results which is separated/ in other XML file. See the photo below. 🙂

view2

PS: you can design your own XML if you want. But I’ll post the java code for this.. 😀

For JAVA

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class LabExam extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        /*
        Button backButton = (Button) findViewById(R.id.backButton);
        backButton.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				setContentView(R.layout.main);
			}
		});*/
        
        
        final Button button = (Button) findViewById(R.id.button1);
        button.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
								
EditText idNumberText = (EditText) findViewById(R.id.idNumberText);
EditText studentNameText = (EditText) findViewById(R.id.nameStudentText);
EditText courseText = (EditText) findViewById(R.id.courseText);
EditText yearLevelText = (EditText) findViewById(R.id.yearLevelText);
				
EditText scoreAssignText = (EditText) findViewById(R.id.assignScoreText);
EditText totalAssignText = (EditText) findViewById(R.id.assignTotalText);
				
EditText scoreQuizzesText = (EditText) findViewById(R.id.quizScoreText);
EditText totalQuizzesText = (EditText) findViewById(R.id.quizTotalText);
				
EditText scoreRecitationText = (EditText) findViewById(R.id.recitationScoreText);
EditText totalRecitationText = (EditText) findViewById(R.id.recitationTotalText);
				
EditText scoreExamText = (EditText) findViewById(R.id.examScoreText);
EditText totalExamText = (EditText) findViewById(R.id.examTotalText);
				
float scoreAssign = Integer.parseInt(scoreAssignText.getText().toString());
float totalAssign = Integer.parseInt(totalAssignText.getText().toString());
				
float scoreQuizzes = Integer.parseInt(scoreQuizzesText.getText().toString());
float totalQuizzes = Integer.parseInt(totalQuizzesText.getText().toString());
        
float scoreRecitation = Integer.parseInt(scoreRecitationText.getText().toString());
float totalRecitation = Integer.parseInt(totalRecitationText.getText().toString());
				
float scoreExam = Integer.parseInt(scoreExamText.getText().toString());
float totalExam = Integer.parseInt(totalExamText.getText().toString());
				
				
setContentView(R.layout.result);
				
TextView resultText = (TextView) findViewById(R.id.resultTextView);
				
				resultText.setText(
						Html.fromHtml(
							"

Semestral Grade Report

" + "ID Number: " + idNumberText.getText().toString() + "
" + "Student Name: " + studentNameText.getText().toString() + "
" + "Course: " + courseText.getText().toString() + "
" + "Year Level: " + yearLevelText.getText().toString() + "

" + "Assignment: " + Math.ceil((scoreAssign / totalAssign) * 10) + "
" + "Quizzes: " + Math.abs((scoreQuizzes / totalQuizzes) * 40) + "
" + "Recitation: " + Math.abs((scoreRecitation / totalRecitation) * 10) + "
" + "Exam: " + Math.abs((scoreExam / totalExam) * 40) + "

" + "Grade: " + Math.floor( ((scoreAssign / totalAssign) * 10) + ((scoreQuizzes / totalQuizzes) * 40) + ((scoreRecitation / totalRecitation) * 10) + ((scoreExam / totalExam) * 40) ) ) ); } }); } }

 

Hope you have a beautiful day~

Tinay, x