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(;
EditText e2 = (EditText)findViewById(;
EditText e3 = (EditText)findViewById(;
TextView t1 = (TextView)findViewById(;
TextView t2 = (TextView)findViewById(;
// 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
//Calculation of the difference in readings by the cost per unit
theSum2 = theSum1*;

Can anyone help me at all? 

Post a Reply


Oldest  Newest  Rating
0 Colm Mc · July 13, 2015

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

Java / Android Development


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

Bucky Roberts Administrator