Tuesday, May 19, 2015

S Pepper. Model Awesome Inc .. Powered by Blogger.


In today's article of the series: A First Program in Small Basic, we will continue with mathematics. Today we will create another interesting feature and very easy to do: a converter measures. I speak from experience: sometimes it is difficult to get this kind of programs do things very specific, simple, easy to use and without many "mariquices" (no interfaces all foo), ie programs that do their job without rodeos. Today we will learn how to make such a program. If you are a Small Basic program, I recommend that you read this series of articles in order. And the articles already published are: First Program in Small Basic - Part 1 First Program in Small Basic - Part 2 First Program in Small Basic - Part 3 First Program in Small Basic - Part 4 As I said, the functionality we will add to our Hello World program is a metric converter. More specifically a converter inches to centimeters. And add this functionality, we have 1 to collect data. In this case what we have to know are two things: the extent pcc to which to convert, and what is the calculation to make this conversion. One we already pcc know: what is the calculation to make this conversion. The calculation is to multiply the value in inches by: 2.54. Now we will have another value of the ask. So we opened our Hello World program and add these lines of code: TextWindow. Write ("Type a value in inches pcc to convert to centimeters:") inch = TextWindow. ReadNumber () Now that we know the value to convert, just do the calculation. conversion = inch * 2:54 Note: note that the Small Basic understands that it is a decimal separator the (point) and not the "," pcc (comma) ".". And show the result. TextWindow. WriteLine (inch + "inches =" + conversion pcc + "cm") Now run the program and see the result. One result may be this:
Full line of code looks like this: TextWindow. Title = "Hello World program!" TextWindow. ForegroundColor = "Green" TextWindow. BackgroundColor = "DarkRed" TextWindow. Write ("What is your name?") Name = TextWindow. pcc Read () TextWindow. WriteLine ("Hello" + name + "!") TextWindow. Write ("What year were you born?") = TextWindow year. ReadNumber () age = Clock. Year - TextWindow year. WriteLine ("Your age is" + age + "years.") TextWindow. Write ("Type a value in inches to convert to centimeters:") inch = TextWindow. ReadNumber () conversion = inch * 2:54 TextWindow. WriteLine (inch + "inches =" pcc + conversion + "cm") With this added functionality can for example know what size in centimeters pcc of your television. In the image above a 23-inch TV is about 58 cm. For today's all in a next article in the series we will further improve our program. And you know, if they have any doubt, just put down here your comment! Next article of the series: A First Program in Small Basic - Part 6
Since it is to ask ... as for space between the values of a variable and a text? Example: TextWindow.WriteLine pcc ("!" "Hello" + name +) to run the result is: OláVariável! pcc and should stay: Variable Hello! (With space between words). Well, I do not know if I was clear, but that's Hug Reply Delete
To have much space is presciso q you space !! Eg TextWindow.WriteLine ("!" "Hello" + name +) Notice the espeça after hello and before! pcc ta ai the secret I have helped João Roberto pcc Reply Delete
S Pepper. Model Awesome Inc .. Powered by Blogger.


No comments:

Post a Comment