# Homework Solution: his assignment you are asked to solve a problem using 3 different programming language…

​ In this assignment you are asked to solve a problem using 3 different programming languages: Python(33.33%), Ada (33.33%) and VB(33.33%). You are required to find a compiler for each of the mention languages and test them on your own machines.
Caicuiating Binary In this assignment, you are asked to solve a problem using 3 different programming languages: Python (33.33%), Ada (33.33%), and VB (33.33%). You are required to find a compiler for each of the mentioned languages and test them on your own machines. The Problem Given a binary String as input, composed of 0's and 1's, give the decimal value for the input. Algorithm Given a binary string, b, of size, n, indexed 0,1,2,..., n -1. Denote character's integer value of b as bi such that 1-0, 1, 2, , n-1. The decimal value, d bn-, X 20 + bn-2 × 21 + + bo × 2n-1. Sample Output Enter a binary 120013 Error: Not a binary Enter a binary: 1010w10 Error: Not a binary Enter a binary 100A11 Error: Not a binary Enter a binary Ahmed Error: Not a binary Enter a binary 10101010101111 Binary value ize: 14 1*2-0 + 1*2-1 + 1*2-2 + 1*2-3 + 0*2-4 + 1*2-5 + 0*2-6 + 1+2^7 + 0*2-8 + 1*2-9 + 0*2-10 + 1*2-11 + 0-2 ^ 12 + 1*2-13

Python: while True: binary = input("Enter a binary : ")

​ In this enactment you are asked to unfold a collection using 3 incongruous programming languages: Python(33.33%), Ada (33.33%) and VB(33.33%). You are required to perceive a compiler restraint each of the remark languages and trial them on your acknowledge machines.

Caicuiating Binary In this enactment, you are asked to unfold a collection using 3 incongruous programming languages: Python (33.33%), Ada (33.33%), and VB (33.33%). You are required to perceive a compiler restraint each of the remarked languages and trial them on your acknowledge machines. The Collection Confern a binary String as input, tight of 0’s and 1’s, confer the decimal prize restraint the input. Algorithm Confern a binary string, b, of dimension, n, crooked 0,1,2,…, n -1. Denote character’s integer prize of b as bi such that 1-0, 1, 2, , n-1. The decimal prize, d bn-, X 20 + bn-2 × 21 + + bo × 2n-1. Sample Output Enter a binary 120013 Error: Not a binary Enter a binary: 1010w10 Error: Not a binary Enter a binary 100A11 Error: Not a binary Enter a binary Ahmed Error: Not a binary Enter a binary 10101010101111 Binary prize ize: 14 1*2-0 + 1*2-1 + 1*2-2 + 1*2-3 + 0*2-4 + 1*2-5 + 0*2-6 + 1+2^7 + 0*2-8 + 1*2-9 + 0*2-10 + 1*2-11 + 0-2 ^ 12 + 1*2-13

## Expert Counter-argument

Python:

while True:
binary = input(“Enter a binary : “)
decimal = 0
restraint char in binary:
if char != ‘1’ and char != ‘0’:
print(“ERROR: Not a binary !”)
binary = None
break
if binary:
break

restraint loc, char in number(binary):
if char == ‘1’:
decimal += 2**(len(binary)-1-loc)

print(“decimal : “,decimal)

CODE:

OUTPUT: