Guest User

Untitled

a guest
Jul 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. package com.hoodeddeath.physicscalculator;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.EditText;
  7. import android.widget.TextView;
  8.  
  9. public class GravityActivity extends AppCompatActivity {
  10.  
  11. @Override
  12. protected void onCreate(Bundle savedInstanceState) {
  13. super.onCreate(savedInstanceState);
  14. setContentView(R.layout.activity_gravity);
  15. }
  16.  
  17. public void calc_Click(View v){
  18. double TEN = 10;
  19. double NEGELEVEN = -11;
  20. double G = 6.67*(Math.pow(TEN,NEGELEVEN));
  21. double TWO = 2;
  22. String mOneText = ((EditText)findViewById(R.id.massOne)).getText().toString();
  23. String aOneText = ((EditText)findViewById(R.id.ampOne)).getText().toString();
  24. String mTwoText = ((EditText)findViewById(R.id.massTwo)).getText().toString();
  25. String aTwoText = ((EditText)findViewById(R.id.ampTwo)).getText().toString();
  26. String distText = ((EditText)findViewById(R.id.distance)).getText().toString();
  27. String aThreeText = ((EditText)findViewById(R.id.ampThree)).getText().toString();
  28.  
  29. double mOne = Double.parseDouble(mOneText);
  30. double aOne = Double.parseDouble(aOneText);
  31. double mTwo = Double.parseDouble(mTwoText);
  32. double aTwo = Double.parseDouble(aTwoText);
  33. double dist = Double.parseDouble(distText);
  34. double aThree = Double.parseDouble(aThreeText);
  35.  
  36. mOne = mOne * aOne;
  37. mTwo = mTwo * aTwo;
  38. dist = dist * aThree;
  39. dist = Math.pow(dist, TWO);
  40.  
  41. double total = (G * mOne * mTwo) / dist;
  42.  
  43. TextView a = (TextView)findViewById(R.id.finalForceLabel);
  44. a.setText((int) total);
  45. }
  46. }
  47.  
  48. double mOne = Double.parseDouble(findViewById(R.id.finalForceLabel).toString());
  49. double aOne = Double.parseDouble(findViewById(R.id.ampOne).toString());
  50. double mTwo = Double.parseDouble(findViewById(R.id.massTwo).toString());
  51. double aTwo = Double.parseDouble(findViewById(R.id.ampTwo).toString());
  52. double dist = Double.parseDouble(findViewById(R.id.distance).toString());
  53. double aThree = Double.parseDouble(findViewById(R.id.ampThree).toString());
  54.  
  55. String someString = ((EditText)findViewById(R.id.ampOne)).getText().toString();
  56.  
  57. double d = Double.parseDouble(someString);
  58.  
  59. Resources r = this.getResources();
  60. r.getString(R.strings.someTextOrWhatever);
  61.  
  62. a.setText(Double.toString(total));
Add Comment
Please, Sign In to add comment