How to resolve the algorithm Dynamic variable names step by step in the Wren programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Dynamic variable names step by step in the Wren programming language

Table of Contents

Problem Statement

Create a variable with a user-defined name. The variable name should not be written in the program text, but should be taken from the user dynamically.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Dynamic variable names step by step in the Wren programming language

Source code in the wren programming language

import "./ioutil" for Input
import "./trait" for Var

System.print("Enter three variables:")
for (i in 0..2) {
    var name  = Input.text("\n  name  : ")
    var value = Input.text("  value : ")
    Var[name] = Num.fromString(value)
}

System.print("\nYour variables are:\n")
for (kv in Var.entries) {
    System.print("  %(kv.key) = %(kv.value)")
}


  

You may also check:How to resolve the algorithm Execute HQ9+ step by step in the Julia programming language
You may also check:How to resolve the algorithm First power of 2 that has leading decimal digits of 12 step by step in the J programming language
You may also check:How to resolve the algorithm Perfect numbers step by step in the Pascal programming language
You may also check:How to resolve the algorithm Square form factorization step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the Pointless programming language