У нас вы можете посмотреть бесплатно Build a Simple Application | Julia Bits | Kovolff или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
This video shows you how to build a simple program in Julia, whichs, based on a user’s age, discern whether this user is a minor or adult, In this program you ask the user to input his age. To obtain the age readline() ist used, i.e. user_age 0 readline() Once the user inputs his age, Julia gets the age as a string. First step would be to convert this age to a number, as we have to compare the age to 18. In Julia you convert a numeric string to a number with the parse function. parse takes in two parameters: the type of number you wish to convert to and the string (aka variable) you wish to conver. I.e. user_age_converted = parse(Int64, user_age) Where do I find all available Julia number types? The link below provides a nice list https://julia-ylwu.readthedocs.io/en/... To test whether a user’s age is above or below 18, we use the if function i.e. if parse(Int64, user_age) [greater equal symbol] 18 println("whaoooo! you're an adult with your ", user_age, "years") else println("oh , being ", user_age, " means you're still a minor") end Note that each if in Julia needs an end statement. If [condition] code fulfilling condition elseif [another condition] code fulfilling another condition else code not fulfilling any condition end Above is the general form of Julia if conditions. You can use as many elseif’s as you need. Note that Julia requires the code belonging to if, elseif or else to be indented. Finally we wanted to have the program go on forever, until the user inputs XX to exit. This is achieved by creating a while loop. i.e. while true println("what is your name? Type XX to quit") user_name = readline() if user_name == "XX" break else println("So your name is ", user_name) println("how old are you? ") user_age = readline() println(typeof(user_age)) if parse(Int64, user_age) [greater equal symbol] 18 println("whaoooo! you're an adult with your ", user_age, "years") else println("oh , being ", user_age, " means you're still a minor") end end end As with the if a whole requires an end statement and the code belonging to the loop to be indented. General form of while while [some condition] loop code end In the while loop above we used a second if statement to enable an exit out of the program. This exit is achieved with the keyword break. #julia #programming #loops