Advertisement
NaxeCode

Untitled

Jan 22nd, 2018
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class Calculator : MonoBehaviour {
  7.  
  8.     public InputField inputfield1;
  9.     public InputField inputfield2;
  10.  
  11.     public Text resultText;
  12.  
  13.    
  14.  
  15.     void Start()
  16.     {
  17.         resultText.text = "0";
  18.     }
  19.  
  20.     public void ProcessCalculation()
  21.     {
  22.         /*
  23.         switch (switch_on)
  24.         {
  25.            
  26.             default:
  27.         }
  28.         */
  29.     }
  30.  
  31.     public void Add()
  32.     {
  33.         float number1 = float.Parse(inputfield1.text);
  34.         float number2 = float.Parse(inputfield2.text);
  35.         resultText.text = (number1 + number2).ToString();
  36.     }
  37.  
  38.     public void Subtract()
  39.     {
  40.         float number1 = float.Parse(inputfield1.text);
  41.         float number2 = float.Parse(inputfield2.text);
  42.         resultText.text = (number1 - number2).ToString();
  43.     }
  44.  
  45.     public void Multiply()
  46.     {
  47.         float number1 = float.Parse(inputfield1.text);
  48.         float number2 = float.Parse(inputfield2.text);
  49.         resultText.text = (number1 * number2).ToString();
  50.     }
  51.  
  52.     public void Devide()
  53.     {
  54.         float number1 = float.Parse(inputfield1.text);
  55.         float number2 = float.Parse(inputfield2.text);
  56.         resultText.text = (number1 / number2).ToString("#.00");
  57.     }
  58.  
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement