Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Functions need complete in ActionScript 3.0 C++ [NEED REPLYS]

Community Beginner ,
Jul 24, 2018 Jul 24, 2018

I am given a problem where I must complete the following code under each function. I attempted the the first function called "function getData()" where you simply put txtinput for global variable named num to define it. However, I am not understanding the rest of the other functions. Seems complicated. I have listed below where the functions are. Your explanations would be much appreciated.

// Name:

// Date:

// Purpose: To convert any number from 10 - 99 to its word representation

// This line makes the button, btnConvert wait for a mouse click

// When the button is clicked, the convertNumber function is called

btnConvert.addEventListener(MouseEvent.CLICK, convertNumber);

// These lines make the textinputs wait for a mouse click

// When any of these components are clicked, the clearLabels function is called

txtinNumber.addEventListener(MouseEvent.CLICK, clearLabels);

// Declare Global Variables

var num:int;         // number from 10 - 99

var tensDigit:int;   // the tens digit

var onesDigit:int;   // the ones digit

// This is the convertNumber function

// e:MouseEvent is the click event experienced by the button

// void indicates that the function does not return a value

function convertNumber(e:MouseEvent):void

{

getData();

if (num < 10 || num > 99){

lblOutput.text = "Invalid number. Enter a number between 10 and 99 inclusive.";

}

else{

lblOutput.text = "";

if (num >= 20) {

tensDigit = Math.floor(num / 10);

onesDigit = num % 10;

tens();

ones();

}

else{

tensDigit = Math.floor(num / 10);

onesDigit = num % 10;

teens();

}

}

}

// This is the getData function

// It gets the number from the user

function getData()

{

// complete the code here

num = int(txtinNumber.text);                       <---------------- Over here which I attempted. not entirely sure if correct.

// This is the tens function

// It outputs the word representation of 20, 30, 40,..,90

function tens()

{

//write the code here

tensdigit = int(txtintensDigit.text);                   <--------------Not understanding this one, I put txtinput for the variable tensdigit because I am aware that you have to define it

}

// This is the ones function

// It outputs the word representaion for any number from 1 - 9 inclusive

function ones()

{

// write the code here

onesdigit = int(txtinonesDigit.text);                <------------Did the same for this one as the one above

}

// This is the teens function

// It outputs the word representation for any number from 10 - 19 inclusive

function teens()

{

// write the code here                       <--------------And this one is just confusing, do not know how to work around this one with the function teens()

}

// This is the clearLabels function

// e:MouseEvent is the click event experienced by the textInput

// void indicates that the function does not return a value

function clearLabels(e:MouseEvent):void

{

     lblOutput.text = "";

}

Here is the program I made. Sorry if its small. You type in a number between 10 - 99, and the number turns into the word. ex 12 = twelve.

240
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 24, 2018 Jul 24, 2018

Are you asking us to do your homework for you?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 24, 2018 Jul 24, 2018
LATEST

Nope, would just like an understanding for the functions I pointed out. what they mean so that I am able to fill it out.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines