Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rsv.stypendy.app;
- import android.support.v7.app.ActionBarActivity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.text.TextUtils;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- import android.view.View;
- public class MainActivity extends ActionBarActivity {
- EditText dys, phy, high, oop, log, eng, ukr, ntd;
- Button buttonres;
- TextView resultofmark;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- dys = (EditText) findViewById(R.id.dys);
- eng = (EditText) findViewById(R.id.eng);
- log = (EditText) findViewById(R.id.log);
- phy = (EditText) findViewById(R.id.phy);
- high = (EditText) findViewById(R.id.high);
- oop = (EditText) findViewById(R.id.oop);
- ukr = (EditText) findViewById(R.id.ukr);
- ntd = (EditText) findViewById(R.id.ntd);
- resultofmark = (TextView) findViewById(R.id.resultofmark);
- buttonres = (Button) findViewById(R.id.buttonres);
- buttonres.OnClickListener(onClick(View v);
- }
- @Override
- public void onClick(final View v) {
- final int DYS = 5, PHY = 5, ENG = 3, UKR = 3, OOP = 4, HIGH = 4, LOG = 3, NTD = 3;
- float result = 0;
- if (TextUtils.isEmpty(dys.getText().toString())
- || TextUtils.isEmpty(phy.getText().toString())
- || TextUtils.isEmpty(log.getText().toString())
- || TextUtils.isEmpty(ukr.getText().toString())
- || TextUtils.isEmpty(eng.getText().toString())
- || TextUtils.isEmpty(oop.getText().toString())
- || TextUtils.isEmpty(ntd.getText().toString())
- || TextUtils.isEmpty(high.getText().toString())
- ) {
- return;
- }
- float COMPLOGIC, HIGHMATH, DYSMATH, TECHDOC, PHYSIC, UKRANIAN, ENGLISH, PROGRAMMING;
- COMPLOGIC = Float.parseFloat(log.getText().toString());
- HIGHMATH = Float.parseFloat(high.getText().toString());
- DYSMATH = Float.parseFloat(dys.getText().toString());
- TECHDOC = Float.parseFloat(ntd.getText().toString());
- PHYSIC = Float.parseFloat(phy.getText().toString());
- UKRANIAN = Float.parseFloat(ukr.getText().toString());
- ENGLISH = Float.parseFloat(eng.getText().toString());
- PROGRAMMING = Float.parseFloat(oop.getText().toString());
- result = COMPLOGIC * LOG + HIGHMATH * HIGH + DYSMATH * DYS + TECHDOC * NTD + PHYSIC * PHY +
- UKRANIAN * UKR + ENGLISH * ENG + PROGRAMMING * OOP;
- result = result / (LOG + HIGH + DYS + NTD + PHY + UKR + ENG + OOP);
- if (result > 71) {
- resultofmark.clearComposingText();
- resultofmark.setText("Є стипендія. Середній бал" + result);
- }
- else
- {
- resultofmark.clearComposingText();
- resultofmark.setText("Нема стипендії. Середній бал" + result);
- }
- // формируем строку вывода
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment