if...else and forms urgent assistance needed
<p>I have an assigment in my univerity, and while I am NOT looking for someone to just give the answer to my assignment, I do need guidance because our professor has been VERY vague, if anyone could help me I would really appreciate it because I have to turn this work in by tomorrow.</p>

<p>Assigment1:</p>

<p>draw a flowchart to solve the following problem and implement it in JavaScript.
Create an HTML form for a dollar store that sells simple items like paper towel; and everything in the store has a price of $1.oo per item. If a customer buys 6 items of any type, he/she will get a 5% of discount. If a customer buys 12 items of any type or above, he/she will get a 10% of discount. The store also handles shipping for the customers. If a customer chooses to ship to anywhere in “PA”, it is free shipping. Otherwise, the customer will pay a flat $5.00 for S&amp;H. The HTML form collects customer name, number of items to buy and shipping state and presents the total price in an alert box. Draw a flowchart for the whole work flow, implement a JavaScript program in the HTML form, and include pseudo code in the program as comments lines.</p>

<p>You can compose this flowchart in MS PPT or Visio and save in an image file.</p>

<p>Your JavaScript program should be implemented in an HTML page. The page could contain an IMG tag to show the flowchart.</p>

<p>Here's what I have and it does NOT work, why?</p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
        &lt;script type="text/javascript"&gt;
            function calculateTotalCost()
            {
                var v &gt;= 12;
                var w &gt;= 6;
                var x = Number of Items;
                var y = Shipping State;
                var z = PA;

                if (x=w)
                    x*0.9;
                else if (x!=w)
                    return false;
                else if (x=v)
                    x*0.95;
                else if (x!=v)
                    x=w
                show(calculateTotalCost);
            }
            function validateForm()
            {
                var x=document.forms["w3_agv"]["First Name"].value;
                if (x==null || x=="")
                {
                    alert("First name must be filled out");
                    return false;
                }

                (function() {
                    var params = getParams();
                    var found = false;
                    for (var n in params) {
                        if (!found) {
                            show("&lt;h1&gt;AGV Dollar Store&lt;/h1&gt;");
                            found = true;
                        }
                    show(n + ": &lt;b&gt;" + params[n] + "&lt;/b&gt;&lt;br/&gt;");
                }
            })();
            function extractItems(paragraph) {
                function numberAt(start, length) {
                    return Number(paragraph.slice(start, start + length));
                }
                return new Number;
            }
            for (var number = 0; number &lt;= 12; number = number + 2)
                alert(number);
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;h1&gt;AGV Dollar Store&lt;/h1&gt;
        &lt;p&gt;Incredible! Everything for only $1.00. Please fill-out our form.&lt;/p&gt;
        &lt;form name="w3_agv" method="GET" action="w3_agv.html"&gt;
            First Name: &lt;input type="text" name="First Name"&gt;&lt;br&gt;
            Last Name: &lt;input type="text" name="Last Name"&gt;&lt;br&gt;
            Number of Items: &lt;input type="number" name="Number of Items"&gt;&lt;br&gt;
            Shipping State: &lt;select name="Shipping State"&gt;
                &lt;option&gt;AL&lt;/option&gt;
                &lt;option&gt;AK&lt;/option&gt;
                &lt;option&gt;AZ&lt;/option&gt;
                &lt;option&gt;AR&lt;/option&gt;
                &lt;option&gt;CA&lt;/option&gt;
                &lt;option&gt;CO&lt;/option&gt;
                &lt;option&gt;CT&lt;/option&gt;
                &lt;option&gt;DE&lt;/option&gt;
                &lt;option&gt;FL&lt;/option&gt;
                &lt;option&gt;GA&lt;/option&gt;
                &lt;option&gt;HI&lt;/option&gt;
                &lt;option&gt;ID&lt;/option&gt;
                &lt;option&gt;IL&lt;/option&gt;
                &lt;option&gt;IN&lt;/option&gt;
                &lt;option&gt;IA&lt;/option&gt;
                &lt;option&gt;KS&lt;/option&gt;
                &lt;option&gt;KY&lt;/option&gt;
                &lt;option&gt;LA&lt;/option&gt;
                &lt;option&gt;ME&lt;/option&gt;
                &lt;option&gt;MD&lt;/option&gt;
                &lt;option&gt;MA&lt;/option&gt;
                &lt;option&gt;MI&lt;/option&gt;
                &lt;option&gt;MN&lt;/option&gt;
                &lt;option&gt;MS&lt;/option&gt;
                &lt;option&gt;MO&lt;/option&gt;
                &lt;option&gt;MT&lt;/option&gt;
                &lt;option&gt;NE&lt;/option&gt;
                &lt;option&gt;NV&lt;/option&gt;
                &lt;option&gt;NH&lt;/option&gt;
                &lt;option&gt;NJ&lt;/option&gt;
                &lt;option&gt;NM&lt;/option&gt;
                &lt;option&gt;NY&lt;/option&gt;
                &lt;option&gt;NC&lt;/option&gt;
                &lt;option&gt;ND&lt;/option&gt;
                &lt;option&gt;OH&lt;/option&gt;
                &lt;option&gt;OK&lt;/option&gt;
                &lt;option&gt;OR&lt;/option&gt;
                &lt;option&gt;PA&lt;/option&gt;
                &lt;option&gt;RI&lt;/option&gt;
                &lt;option&gt;SC&lt;/option&gt;
                &lt;option&gt;SD&lt;/option&gt;
                &lt;option&gt;TN&lt;/option&gt;
                &lt;option&gt;TX&lt;/option&gt;
                &lt;option&gt;UT&lt;/option&gt;
                &lt;option&gt;VT&lt;/option&gt;
                &lt;option&gt;VA&lt;/option&gt;
                &lt;option&gt;WA&lt;/option&gt;
                &lt;option&gt;WV&lt;/option&gt;
                &lt;option&gt;WI&lt;/option&gt;
                &lt;option&gt;WY&lt;/option&gt;
            &lt;/select&gt;&lt;br&gt;
            &lt;p&gt;
                &lt;input type="button" value="Submit" onclick="calculateTotalCost()"&gt;
            &lt;/p&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Assignment2:</p>

<p>draw a flowchart to solve the following problem and implement it in JavaScript.
Create a JavaScript program that takes a sentence and convert that to “pig Latin”.
Clue:
- You will need to use a string function “split” to split the sentence to an array of words.
- Find what an array is and how to iterate through every element in the array.
- Check Wikipedia “Pig Latin” article to find how to translate a word to its “Pig Latin” form. This will constitute the “repeated task” step.</p>

<p>Here's the professors example which does NOT give much to go on:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    //prompt for word to convert and index variable to hold the position of the 1st vowel
    var word = prompt("Enter word to convert here","");
    var index;

    function doGetCaretPosition (ctrl) {
        var CaretPos = 0;
        if (document.selection) {
            ctrl.focus ();
            var Sel = document.selection.createRange ();
            Sel.moveStart ('character', -ctrl.value.length);
            CaretPos = Sel.text.length;
        } else if (ctrl.selectionStart || ctrl.selectionStart == '0') {
            CaretPos = ctrl.selectionStart;
        }
        return (CaretPos);
    }
    //find the first vowel and convert the word to pig latin
    index = word.search(/[aeiouAEIOU]/);
    if (index &lt;= 0) {
        var pigLatin= word + "way"; 
    }
    else { 
        var pigLatin = word.substring(index, word.length) + word.substring(0,index) + "ay"; 
    }

    alert(pigLatin);

&lt;/script&gt;
</code></pre>

<p>PLEASE assist me with this problem!</p>
