# Calculator not working

**URL:** <https://forum.kirupa.com/t/calculator-not-working/321463>\
**Category:** Uncategorized\
**Created:** [April 20, 2011, 1:30pm UTC](https://forum.kirupa.com/t/calculator-not-working/321463 "2011-04-20T13:30:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![moonlitxkiss](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@moonlitxkiss](https://forum.kirupa.com/u/moonlitxkiss)\
**Post date:** [April 20, 2011, 1:30pm UTC](https://forum.kirupa.com/t/calculator-not-working/321463/1 "2011-04-20T13:30:10Z")

</div>

[FONT=Verdana][SIZE=2][COLOR=Black]I’m in a Web Design class and atm, I’m working on chapter 8 of Flash CS5 case problem.

I have to make a calculator. Can I just say that AS3 makes me frusterated? D:

Anyway, after I finished what the book told me to do whilst getting confused in some areas, I got many compiler errors. I managed to get rid of them but in the end, my calculator isn’t working, haha.

Here’s the whole code:

import flash.events.MouseEvent;  
calcTotal\_btn.addEventListener(MouseEvent.CLICK, calculateTourCost);  
function calculateTourCost(event:MouseEvent):void {

```
var totalCost:Number;
var base_cost:Number;
var people:Number = int(numberOfPeople.text);
var cost_per_person:Number;
if (people &lt; 8)
{
    cost_per_person = 10;
}
if (people &lt; 7 &gt; 16)
{
    cost_per_person = 8;
}
if (people &lt; 15)
{
    cost_per_person = 5;
}

//Use the switch statement to assign the tour's base cost
switch (tourType_txt.text)
{
    case "A" :
    case "a" :
        base_cost = 20;
        break;
    case "B" :
    case "b" :
        base_cost = 25;
        break;
    case "C" :
    case "c" :
        base_cost = 30;
        break;
    default :
        base_cost = 40;
}

//Determines total cost
people = int(numberOfPeople) + int(base_cost);
totalCost = people * cost_per_person;
totalCost = (totalCost);

```

}

If anyone can help me out, I’d greatly appreciate it.  
[/COLOR][/SIZE][/FONT]
