This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB.NET Basic Calculator
#1
Code:
function add(x, y) 
  return x + y
end function
function subtract(x, y) 
  return x - y
end function
function multiply(x, y) 
  return x * y
end function
function divide(x, y) 
  return x / y
end function

console.writeline("Select symbol.")
console.writeline("1.add\n2.sub\n3.mul\n4.div") 

console.writeline("Enter choice (1,2,3 or 4):")
dim choice  as integer= integer.parse(console.readline)

console.writeline("Enter first number: ")
dim  num1 as integer= integer.parse(console.readline)

console.writeline("Enter second number:")
dim num2  as integer= integer.parse(console.readline)
if choice = "1" then
  console.writeline(num1 & "+" & num2 & "=" & add(num1,num2))

else if choice = "2" then
  console.writeline(num1 & "-" & num2 & "=" & subtract(num1,num2))

else if choice = "3" then
  console.writeline(num1 & "*" & num2 & "=" & multiply(num1,num2))

else if choice = "4" then
  console.writeline(num1 & "/" & num2 & "=" & divide(num1,num2))
else 
  console.writeline("Invalid symbol")
end if
Disclaimer: Don't be misguided looking at my usergroup and assume whatever I say is official. When I speak in community I am just a member with personal opinions.
Reply


Messages In This Thread
VB.NET Basic Calculator - by jamie - 07/07/2018, 02:19 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)
www.000webhost.com