![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: help, tge, torquescript |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| //================================================== =========================== // Fruit.cs // // This program adds up the costs and quantities of selected fruit types // and outputs the results to the display //================================================== =========================== function runFruit() //------------------------------------------------------- // Entry point for the program. //------------------------------------------------------- { $bananoCost=1.15; // intitialize the value of our variables $appleCost=0.55; // (we don't need to repeat the above $numApples=3; // comment for each inititalization, just $numBananas=1; // group the init statements together.) $numFruit=0; // always a good idea to initialize *all* variables! $total=0; // (even if we know we are going to change them later) echo("Cost of Bananas(ea.):$"@$bananaCost); // the value of $bananaCost gets concatenated to the end // of the "Cost of Bananas:" string. Then the // full string gets echoed. same goes for the next 3 lines echo("Cost of Apples (ea.):$"@$appleCost); echo("Number of Bananas:"@$numBananas); echo("Number of Apples:"@$numApples); $numFruit=$numBananas + $numApples; // add up the total number of fruits $total= ($numBananas * $bananaCost) + ($numApples * $appleCost)// calculate the total cost // (notice that statements can extend beyond a single line) echo("Total amount of Fruit:"@$numFruit); // output the results echo("Total Price of Fruit:"@$total@"0"); // add zero to the end // to make it look better on the screen } |
| |
| |||
| I have no knowledge of TorqueScript, but it appears you missed a semicolon: PHP Code: __________________ "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." -- Bjarne Stroustrup, creator of what is now known as C++ For more quotes by Bjarne Stroustrup, check out http://www.research.att.com/~bs/bs_faq.html#really-say-that. |
| The Following 2 Users Say Thank You to rpgfan3233 For This Useful Post: | ||
HelloWorld (08-15-2007), TeraTask (08-13-2007) | ||
| ||||
| May I suggest that you put all the Global variables outside of the function, otherwise if you decide to change them while in-game every time the function's called they'll be set back. |
| The Following User Says Thank You to MrPickle For This Useful Post: | ||
HelloWorld (11-15-2007) | ||
![]() |
| Thread Tools | |
| Display Modes | |
| |