Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Calculator : MonoBehaviour {
- public InputField inputfield1;
- public InputField inputfield2;
- public Text resultText;
- void Start()
- {
- resultText.text = "0";
- }
- public void ProcessCalculation()
- {
- /*
- switch (switch_on)
- {
- default:
- }
- */
- }
- public void Add()
- {
- float number1 = float.Parse(inputfield1.text);
- float number2 = float.Parse(inputfield2.text);
- resultText.text = (number1 + number2).ToString();
- }
- public void Subtract()
- {
- float number1 = float.Parse(inputfield1.text);
- float number2 = float.Parse(inputfield2.text);
- resultText.text = (number1 - number2).ToString();
- }
- public void Multiply()
- {
- float number1 = float.Parse(inputfield1.text);
- float number2 = float.Parse(inputfield2.text);
- resultText.text = (number1 * number2).ToString();
- }
- public void Devide()
- {
- float number1 = float.Parse(inputfield1.text);
- float number2 = float.Parse(inputfield2.text);
- resultText.text = (number1 / number2).ToString("#.00");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement