• 0

BINARY CALCULATOR IN TURING


Question

here is the program which adds and subtracts but how do i get it to do it in binary

var str1, str2 : string

var num1, num2 : int

get str1

get str2

num1 := strint (str1, 2)

num2 := strint (str2, 2)

put "The total is ", intstr (num1 + num2, 0, 2), "."

put "The total is ", intstr (num1 - num2, 0, 2), "."

Here is my calculator program would you be able to show me where to place the code above in order for it to work. Also how do i make my buttons clickable and display the number which is being clicked.

setscreen ("graphics:640;480")

proc optionmenu (var choice, font2 : int)

loop

colorback (blue)

cls

color (white)

font2 := Font.New ("Arial:19")

Font.Draw ("ADDING & SUBTRACTING BINARY CALCULATOR", 50, 400, font2, white)

Font.Draw ("Please enter your desired choice? Then type enter!", 50, 350, font2, white)

Font.Draw ("1. START", 50, 300, font2, white)

Font.Draw ("2. EXIT", 50, 250, font2, white)

locate (20, 40)

get choice

exit when choice = 1 or choice = 2

end loop

end optionmenu

proc calculatordesign

drawbox (120, 200, 190, 260, white)

cls

color (white)

drawfillbox (170, 250, 240, 310, brightred)

locatexy (205, 280)

put "1" ..

drawfillbox (360, 250, 430, 310, brightblue)

locatexy (395, 280)

put "0" ..

drawfillbox (170, 170, 240, 230, green)

locatexy (205, 200)

put "+" ..

drawfillbox (360, 170, 430, 230, yellow)

locatexy (395, 200)

put "-" ..

drawfillbox (270, 90, 340, 150, grey)

locatexy (295, 120)

put "Hex" ..

drawfillbox (360, 90, 430, 150, purple)

locatexy (395, 120)

put "=" ..

drawfillbox (270, 310, 340, 250, white)

locatexy (305, 280)

put "C" ..

drawfillbox (170, 90, 240, 150, brightgreen)

locatexy (195, 120)

put "Dec" ..

end calculatordesign

proc getValue (var A : array 1 .. 8 of int, var B : array 1..8 of int)

var x, y, bnum, bud : int

var count : int := 1

for i : 1 .. 1

A (i) := 0

end for

buttonwait ("down", x, y, bnum, bud)

loop

if x > 170 and x < 240 and y > 310 and y < 370 then

A (count) := 1

count := count + 1

elsif x > 170 and x < 240 and y > 230 and y < 290 then

for i : 1 .. 8

put A (i) ..

A (count) := 0

count := count - 1

end for

end if

locatexy (1, maxy)

for i : 1 .. count + 1

put A (i) ..

end for

locatexy (1, maxy)

buttonwait ("down", x, y, bnum, bud)

for c : 1 .. 8

put B © ..

B (count):= 1

count := count + 1

end for

exit when count = 9

end loop

end getValue

proc showanswer (var num1, num2 : int)

put "The total is ", intstr (num1 + num2, 0, 2), "."

put "The total is ", intstr (num1 - num2, 0, 2), "."

end showanswer

var x, y, bnum, bud : int

var choice : int

var A, B : real

var font2 : int

var num1, num2 : int

optionmenu (choice, font2)

loop

exit when choice = 2

end loop

calculatordesign

getValue (A, B)

showanswer (num1, num2)

loop

exit when hasch

end loop

*****************could you please let me know what is wrong with this code ive been trying to get it to work but its not working no matter what i do*******************

Link to comment
https://www.neowin.net/forum/topic/423119-binary-calculator-in-turing/
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Elden Ring Nightreign will finally gain ‘Duo Expeditions' next week by Pulasthi Ariyasinghe FromSoftware's latest project, Elden Ring Nightreign, delivered a multiplayer-focused experience for the first time. While the title offered solo runs as an alternative to its standard three-player Trio Expeditions, Duos were surprisingly missing at launch. A couple of months later, the developer is finally delivering this highly requested feature for the hit roguelike. On social media, the studio confirmed that Duo Expeditions will be hitting Elden Ring Nightreign with the next update, patch 1.02, for the game on July 30. Check out the newly released trailer showing off this mode below. As we mentioned in our review of Elden Ring Nightreign, everything from enemy health, boss aggression, player damage, and even XP gain changes depending on how many players are in the Expedition. A post-launch update even tweaked the difficulty to favor solos as well. Duos should have the same changes being applied, with the mode being easier than trios but harder than solos to complete. Making sure the difficulty is properly balanced has previously been given as the reason why the Duos mode has taken a while to come in. FromSoftware also confirmed that patch 1.02 will have a range of more quality-of-life improvements on the UI side. This will include more Relics filtering options, making custom builds easier to construct before going on new runs, as seen below. Publisher Bandai Namco also announced this week that the Elden Ring Shadow of the Erdtree expansion for the original open-world Soulslike recently passed 10 million players. Meanwhile, this Elden Ring Nightreign spin-off now has over 5 million players, making both massive successes for the publisher. While FromSoftware is now focusing on other projects, Bandai Namco isn't done with the Elden Ring universe just yet either, as a live-action movie has now been confirmed to be in development too.
    • Or you ignore the part where @Michael Scrip answered you directly.
    • The reasons for Microsoft being in near perpetual state of reorganization for two years is due to the 6 CapEx acquisitions between Jan 2022 and Jan 2023, Blizzard, Oribi, Minit, Miburo, Lumenisity and Fungible. There were 15 CapEx acquisitions in 2021 alone. Much like the Borg, Microsoft assimilates knowledge instead of expending resources on learning and development. 10 gaming companies, 3 AI and 1 data modeling companies since 2018. But then this is in the founding DNA of Microsoft, MS DOS wasn't made by MS, Windows was based on the Apple Mac and Xerox PARC Alto....and on and on. (To be fair Apple's Lisa and Mac were from the Alto also)
    • Can't get a pic of the physical server as it's in a DC, but what i'm running on it is doable. All for my own use except one VM used by a friend to run her site and other things.
    • Immediately using a VPN that makes me appear to be in the EU.
  • Recent Achievements

    • Very Popular
      d4l3d earned a badge
      Very Popular
    • Dedicated
      Stephen Leibowitz earned a badge
      Dedicated
    • Dedicated
      Snake Doc earned a badge
      Dedicated
    • One Month Later
      Philsl earned a badge
      One Month Later
    • One Month Later
      armandointerior640 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      629
    2. 2
      ATLien_0
      237
    3. 3
      Xenon
      163
    4. 4
      neufuse
      123
    5. 5
      +FloatingFatMan
      123
  • Tell a friend

    Love Neowin? Tell a friend!