-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
47 lines (30 loc) · 1.12 KB
/
MainActivity.java
File metadata and controls
47 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.sies.tempvert;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private Button button;
private TextView textView;
private EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.button2);
textView = findViewById(R.id.textView5);
editText = findViewById(R.id.editTextNumber2);
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
String g = editText.getText().toString();
double fn = Integer.parseInt(g);
double cs = (fn-32)*0.55556;
textView.setText("Temperature in Celsius is"+ " " + cs + "°C");
}
});
}
}