---
# System prepended metadata

title: 9/29 Typesetting/ Celsius trans into Fahrenheit
tags: [android, typesetting]

---

# 9/29 Typesetting/ Celsius trans into Fahrenheit


###### tags: `android` `typesetting`

> [TOC]
> 
## Celsius trans into Fahrenheit

```
package com.example.project1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void buttonClick (View view){
        EditText txtTemp = findViewById(R.id.txtTemp);
        int tmp = Integer.parseInt(txtTemp.getText().toString());

        double result = (9.0*tmp)/5.0 + 32.0;

        TextView tempF = findViewById(R.id.tempF);
        tempF.setText("F" + result);
    }
}
```

![](https://i.imgur.com/LguVxVj.png)


## Typesetting


public void buttonClick(View view){  
        TextView cm = findViewById(R.id.cm);  
   TextView kg = findViewById(R.id.kg);  
  
//        int cmNumber = Integer.parseInt(cm.getText().toString());  
//        int kgNumber = Integer.parseInt(cm.getText().toString());  
  
   double cmNumber = Double.parseDouble(cm.getText().toString());  
 double kgNumber = Double.parseDouble(kg.getText().toString());  
  
   //calculate BMI  
   double mNumber = cmNumber/100;  
 double BMI = kgNumber/(mNumber*mNumber);  
  
   TextView result = findViewById(R.id.result);  
   result.setText("BMI: "\+ BMI);  
   }  
  
    public void clearClick(View view){  
        TextView cm = findViewById(R.id.cm);  
   TextView kg = findViewById(R.id.kg);  
   TextView result = findViewById(R.id.result);  
  
   cm.setText("0");  
   kg.setText("0");  
   result.setText("0");  
   }


Layout 
![](https://i.imgur.com/YeSCYjP.png)


Click calculate button 
![](https://i.imgur.com/5SYMgw2.png)

Click clear button 
![](https://i.imgur.com/IS8fWxR.png)




## occur problem 

### virtual Phone machine CRASH

solve way 

Power off the computer 

And then go to the Device management 

Click Cold boot now 

![](https://i.imgur.com/elnKIVJ.png)
