Creating a calcuator in Android

0 Colm Mc · July 13, 2015
At the minute, i am creating a calculator where the user enters two numbers and the second number is then taken away by the first number ( i have that part) and then the second part is where the user enters a number in which the difference of the first 2 numbers is then mulitiplied and then returned at the bottom of the screen. 

I am currently stuck at the second part of the caulcation where im not sure how to calculate the second part of the caulcaution in which the first sum is then muliptled. 

Below is my code

public void onButtonClick(View v){
int n1,n2,n3, theSum1,theSum2, totalSum;
//Matches the id that were assigned on the @+id/....
EditText e1 = (EditText)findViewById(R.id.num1);
EditText e2 = (EditText)findViewById(R.id.num2);
EditText e3 = (EditText)findViewById(R.id.sum1);
TextView t1 = (TextView)findViewById(R.id.sum1);
TextView t2 = (TextView)findViewById(R.id.sum2);
// Conversion below of the num1 and num2 to integers to enable calculation
n1 = Integer.parseInt(e1.getText().toString());
n2 = Integer.parseInt(e2.getText().toString());
n3 = Integer.parseInt(e3.getText().toString());
//Calculation of the first and second reading
theSum1 = n2-n1;
//Returning it as a string
t1.setText(Integer.toString(theSum1));
//Calculation of the difference in readings by the cost per unit
theSum2 = theSum1*;

Can anyone help me at all? 

Post a Reply

Replies

Oldest  Newest  Rating
0 Colm Mc · July 13, 2015
/images/forum/upload/2015-07-13/d2ea34306587d6641be6ee81298b6eda.png


Here is what the screen looks like if it makes any help
  • 1

Java / Android Development

107,139 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator