Guest User

ff

a guest
Jun 14th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.92 KB | None | 0 0
  1. package com.rsv.stypendy.app;
  2.  
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.os.Bundle;
  5. import android.view.Menu;
  6. import android.view.MenuItem;
  7. import android.text.TextUtils;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.TextView;
  11. import android.view.View;
  12. public class MainActivity extends ActionBarActivity {
  13.     EditText dys, phy, high, oop, log, eng, ukr, ntd;
  14.     Button buttonres;
  15.     TextView resultofmark;
  16.  
  17.     @Override
  18.     protected void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.activity_main);
  21.         dys = (EditText) findViewById(R.id.dys);
  22.         eng = (EditText) findViewById(R.id.eng);
  23.         log = (EditText) findViewById(R.id.log);
  24.         phy = (EditText) findViewById(R.id.phy);
  25.         high = (EditText) findViewById(R.id.high);
  26.         oop = (EditText) findViewById(R.id.oop);
  27.         ukr = (EditText) findViewById(R.id.ukr);
  28.         ntd = (EditText) findViewById(R.id.ntd);
  29.         resultofmark = (TextView) findViewById(R.id.resultofmark);
  30.         buttonres = (Button) findViewById(R.id.buttonres);
  31.         buttonres.OnClickListener(onClick(View v);
  32.     }
  33. @Override
  34.     public void onClick(final View v) {
  35.         final int DYS = 5, PHY = 5, ENG = 3, UKR = 3, OOP = 4, HIGH = 4, LOG = 3, NTD = 3;
  36.         float result = 0;
  37.  
  38.  
  39.         if (TextUtils.isEmpty(dys.getText().toString())
  40.                 || TextUtils.isEmpty(phy.getText().toString())
  41.                 || TextUtils.isEmpty(log.getText().toString())
  42.                 || TextUtils.isEmpty(ukr.getText().toString())
  43.                 || TextUtils.isEmpty(eng.getText().toString())
  44.                 || TextUtils.isEmpty(oop.getText().toString())
  45.                 || TextUtils.isEmpty(ntd.getText().toString())
  46.                 || TextUtils.isEmpty(high.getText().toString())
  47.                 ) {
  48.             return;
  49.         }
  50.  
  51.  
  52.         float COMPLOGIC, HIGHMATH, DYSMATH, TECHDOC, PHYSIC, UKRANIAN, ENGLISH, PROGRAMMING;
  53.  
  54.  
  55.         COMPLOGIC = Float.parseFloat(log.getText().toString());
  56.         HIGHMATH = Float.parseFloat(high.getText().toString());
  57.  
  58.         DYSMATH = Float.parseFloat(dys.getText().toString());
  59.  
  60.         TECHDOC = Float.parseFloat(ntd.getText().toString());
  61.  
  62.         PHYSIC = Float.parseFloat(phy.getText().toString());
  63.  
  64.         UKRANIAN = Float.parseFloat(ukr.getText().toString());
  65.  
  66.         ENGLISH = Float.parseFloat(eng.getText().toString());
  67.  
  68.         PROGRAMMING = Float.parseFloat(oop.getText().toString());
  69.  
  70.  
  71.         result = COMPLOGIC * LOG + HIGHMATH * HIGH + DYSMATH * DYS + TECHDOC * NTD + PHYSIC * PHY +
  72.                 UKRANIAN * UKR + ENGLISH * ENG + PROGRAMMING * OOP;
  73.         result = result / (LOG + HIGH + DYS + NTD + PHY + UKR + ENG + OOP);
  74.  
  75.  
  76.         if (result > 71) {
  77.             resultofmark.clearComposingText();
  78.             resultofmark.setText("Є стипендія. Середній бал" + result);
  79.  
  80.         }
  81.         else
  82.         {
  83.             resultofmark.clearComposingText();
  84.             resultofmark.setText("Нема стипендії. Середній бал" + result);
  85.  
  86.         }
  87.  
  88.  
  89.         // формируем строку вывода
  90.  
  91.     }
  92.  
  93.  
  94.  
  95.  
  96.     @Override
  97.     public boolean onCreateOptionsMenu(Menu menu) {
  98.        
  99.         // Inflate the menu; this adds items to the action bar if it is present.
  100.         getMenuInflater().inflate(R.menu.main, menu);
  101.         return true;
  102.     }
  103.  
  104.     @Override
  105.     public boolean onOptionsItemSelected(MenuItem item) {
  106.         // Handle action bar item clicks here. The action bar will
  107.         // automatically handle clicks on the Home/Up button, so long
  108.         // as you specify a parent activity in AndroidManifest.xml.
  109.         int id = item.getItemId();
  110.         if (id == R.id.action_settings) {
  111.             return true;
  112.         }
  113.         return super.onOptionsItemSelected(item);
  114.     }
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment