Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hoodeddeath.physicscalculator;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.EditText;
- import android.widget.TextView;
- public class GravityActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_gravity);
- }
- public void calc_Click(View v){
- double TEN = 10;
- double NEGELEVEN = -11;
- double G = 6.67*(Math.pow(TEN,NEGELEVEN));
- double TWO = 2;
- String mOneText = ((EditText)findViewById(R.id.massOne)).getText().toString();
- String aOneText = ((EditText)findViewById(R.id.ampOne)).getText().toString();
- String mTwoText = ((EditText)findViewById(R.id.massTwo)).getText().toString();
- String aTwoText = ((EditText)findViewById(R.id.ampTwo)).getText().toString();
- String distText = ((EditText)findViewById(R.id.distance)).getText().toString();
- String aThreeText = ((EditText)findViewById(R.id.ampThree)).getText().toString();
- double mOne = Double.parseDouble(mOneText);
- double aOne = Double.parseDouble(aOneText);
- double mTwo = Double.parseDouble(mTwoText);
- double aTwo = Double.parseDouble(aTwoText);
- double dist = Double.parseDouble(distText);
- double aThree = Double.parseDouble(aThreeText);
- mOne = mOne * aOne;
- mTwo = mTwo * aTwo;
- dist = dist * aThree;
- dist = Math.pow(dist, TWO);
- double total = (G * mOne * mTwo) / dist;
- TextView a = (TextView)findViewById(R.id.finalForceLabel);
- a.setText((int) total);
- }
- }
- double mOne = Double.parseDouble(findViewById(R.id.finalForceLabel).toString());
- double aOne = Double.parseDouble(findViewById(R.id.ampOne).toString());
- double mTwo = Double.parseDouble(findViewById(R.id.massTwo).toString());
- double aTwo = Double.parseDouble(findViewById(R.id.ampTwo).toString());
- double dist = Double.parseDouble(findViewById(R.id.distance).toString());
- double aThree = Double.parseDouble(findViewById(R.id.ampThree).toString());
- String someString = ((EditText)findViewById(R.id.ampOne)).getText().toString();
- double d = Double.parseDouble(someString);
- Resources r = this.getResources();
- r.getString(R.strings.someTextOrWhatever);
- a.setText(Double.toString(total));
Add Comment
Please, Sign In to add comment