Create a 'simple' calculator. The calculator should be able to add, subtract, multiply, and divide two numbers.
You can use whatever format you want to receive the numbers (such as textboxes). You also can use whatever method (such as a button for each operation +, -, *, /) to determine what operation the user wants to accomplish.
The output should be displayed in a similar format to "1 + 2 = 3" or "1 - 2 = -1".
Make sure to use meaningful variable names. Make sure to give your application a meaningful name like"myCalculator". Make sure to change the form name to something meaningful. Include comments in your program that has your name and the assignment number.
Below is the solution:
Public Class myCalculator
Private Sub myCalculator_Load(sender As
Object, e As EventArgs) Handles MyBase.Load
CenterToScreen()
'display in center to screen
End Sub
Private Sub btnCalcule_Click(sender As
Object, e As EventArgs) Handles btnCalcule.Click
Dim total As Double = 0
''declare total variable
txtAnswer.Text = ""
''set the answer textbox to empty
Dim no1, no2 As Integer
'declare no1 and no2 variable
If Not
Int32.TryParse(txtNumber1.Text, no1) Then 'chcek for the integer
value 1
MessageBox.Show("Number 1 is not integer")
ElseIf Not
Int32.TryParse(txtNumber2.Text, no2) Then 'chcek for the integer
value 2
MessageBox.Show("Number 2 is not integer")
ElseIf rbtnAdd.Checked =
True Then 'check if Add button is selected
total = no1 + no2
txtAnswer.Text = no1 & " + " & no2 & " = " &
total
ElseIf rbtnSub.Checked =
True Then 'check if Subtract button is selected
total = no1 - no2
txtAnswer.Text = no1 & " - " & no2 & " = " &
total
ElseIf rbtnMul.Checked =
True Then 'check if Multiply button is selected
total = no1 * no2
txtAnswer.Text = no1 & " * " & no2 & " = " &
total
ElseIf no2 = 0 Then
'check if the second number is zero
MessageBox.Show("Number can not divided by 0")
ElseIf rbtnDiv.Checked =
True Then 'check if Divide button is selected
total = no1 / no2
txtAnswer.Text = no1 & " / " & no2 & " = " &
total
Else
MessageBox.Show("Select for calculation") 'error if not selected
operation
End If
End Sub
End Class
output:
Create a 'simple' calculator. The calculator should be able to add, subtract, multiply, and divide two...
Task 6: Write a Java program to make a calculator. The calculator should add, subtract, multiply and divide the numbers inserted by the user. Feel free to add more operations to your calculator, such as power, sqrt etc. (Hint: Use Switch)
Create a C++ calculator that allows you to add, multiply, divide, or subtract, and allows you to inlcude an infinite amount of inputted numbers for it.
Calculator = 0.01 Calculate . Add O subtract O Multiply ODvide uttons on the right determine the operation that is performed on the numbers. For example, the following image shows values 12 and 3 are entered in the ion in selected. When the Calculate button is pressed, the result of the addition operation is shown after the equal sign ( In this example, the result is 1 Calculator 12 .15.01 Calculate | ⓔAdd subtract。Multiply O Divide g images show the...
Build a basic calculator app in swift. Calculator must be able to add, subtract, multiply, divide, and compute sine, cosine, and tangent functions. The core calculator arithmetic logic should be written as an objective c framework that is used in the swift app.
Could you code this question on Matlab? :) Question: Design a GUI based application, named Calculator, which perform basic arithmetic operations ie., add, subtract, multiply, and divide Your design must have 1) Two separate input fields for reading the two operands (let's say a and b) 2) 4 Four button (labeled as +, -, *, /) to let the user select an operation. 3) An output field for displaying the result Following table shows operations performed on pushing each of...
Write a calculator that will give the user this menu options: 1)Add 2)Subtract 3)Multiply 4)Divide 5)Exit . Your program should continue asking until the user chooses 5. If user chooses to exit give a goodbye message. After the user selections options 1 - 4, prompt the user for two numbers. Perform the requested mathematical operation on those two numbers. Round the result to 1 decimal place. Please answer in python and make it simple. Please implement proper indentation, not just...
IN PYTHON! Create a calculator GUI. The GUI should let the user add, subtract, multiply, and divide two numbers they input. All user input and the result displayed to the user should be seen in the GUI itself (i.e. the terminal should not show anything). Thank you very much! PLEASE PASTE IN HERE THE RIGHT INDENTS
Write the functions to add, subtract, multiply and divide two doubles. The function returns the result on the operation. Write a program to test your functions. In visual studios console application C#.
1.Write a Python program to perform simple arithmetic operations (add, subtract, multiply and divide) on 2 numbers and display the output on console ( use methods in your program) Range of numbers : 1 to 100 (Do not use 0)
Create a simple calculator. Your interface should contain two input boxes in which the user can put two numbers. There should be four buttons: add, subtract, multiply, and divide. When the user inputs two number and clicks on an operation button, the result should be displayed in the label. Can some please help my code that i came up with just displays a pop box with no words or nothing! I'm not the best at coding. Any tips or advice...