Conditional Conjunctions

Nesting a Conditional Statement

A conditional statement has a body, which is from where the condition is defined to where its behavior ends. In the body of the conditional statement, you can create another conditional statement. This is referred to as nesting the condition. In a method of a class, the condition nesting can be formulated as follows:

if( condition1 )     // The nesting, main, parent, first, or external condition
    if( condition2 ) // The nested, child, second, or internal condition
    	statement(s)

If you are writing your code in a webpage, each condition must be delimitad by curly brackets:

if( condition1 )
{    
    if( condition2 )
    {
        statement(s)
    }
}

In the same way, you can nest one conditional statement in one, then nest that new one in another conditional statement, and so on. In a method, this can be formulated as follows:

if( condition1 )
    if( condition2 )
        if( condition3 )
            statement(s)

Remember, in the code of a webpage, each statement must be included in curly brackets:

if( condition1 )
{    
    if( condition2 )
    {    
        if( condition3 )
	{    
            statement(s)
        }
    }
}

Practical LearningPractical Learning: Introducing Boolean Conjunctions

  1. Start Microsoft Visual Studio
  2. On the main menu of Microsoft Visual Studio, click File -> New -> Project...
  3. In the middle list, click ASP.NET Application (.NET Framework) and set the project Name to StockBrokerCompany1
  4. Click OK
  5. In the New ASP.NET Web Application dialog box, click Empty and press Enter
  6. IOn the main menu, click Project -> New Folder
  7. Type Content and press Enter
  8. In the Solution Explorer, right-click Content -> Add -> New Item...
  9. In the left frame of the Add New Item dialog box, click Web and, in the middle frame, click Style Sheet
  10. Replace the name with Site
  11. Click Add
  12. Change the code as follows:
    .container {
        width: 300px;
        margin: auto; }
    .boldness   { font-weight: bold }
    .col-format { width: 150px;     }
    .col-second { width: 120px;     }
  13. In the Solution Explorer, right-click StockBrokerCompany1 -> Add -> Add ASP.NET Folder -> App_Code
  14. In the Solution Explorer, right-click App_Code -> Add -> New Item...
  15. In the left frame of the Add New Item dialog box, expand Web and click Razor
  16. In the middle list, click Helper (Razor v3)
  17. Replace the name with StocksProcessing
  18. Click Add

Boolean Conjunctions

Remember that you can nest one condition in another condition as in:

if( condition1 )
    if( condition2 )
    statement(s)

Or:

if( condition1 )
{    
    if( condition2 )
    {
        statement(s)
    }
}

When you nest a condition, you are in fact indicating that "if condition1 verifies, then if condition2 verifies, do this...". The external condition must be verified first as being true or false (depending on how you wrote the conditional statement). If that first (the external) condition is true, the second (the internal) condition is checked. If the first (or external) condition is not valid, the second (the internal) condition is not evaluated. To support a simplified technique to apply this description, the C# language provides the Boolean "AND" operator, represented as &&. Its primary formula is:

condition1 && condition2

You must formulate each condition to produce a true or a false result. The result is as follows:

Practical LearningPractical Learning: Introducing Boolean Conjunctions

  1. Create a helper as follows:
    @helper Trade(decimal numberOfShares, decimal pricePerShare) {
        decimal principal = 0.00m;
        decimal commission = 0.00m;
        string strCommission = "";
        string strPrincipal = "0.00";
        string strTotalInvestment = "";
    
        principal = numberOfShares * pricePerShare;
    
        if (principal >= 0m && principal <= 2500m)
        {
            commission = 26.25m + (principal * 0.0014m);
        }
    
        if (principal > 2500m && principal <= 6000m)
        {
            commission = 45.00m + (principal * 0.0054m);
        }
        if (principal > 6000m && principal <= 20000m)
        {
            commission = 60.00m + (principal * 0.0028m);
        }
    
        if (principal > 20000m && principal <= 50000m)
        {
            commission = 75.00m + (principal * 0.001875m);
        }
    
        if (principal > 50000m && principal <= 500000m)
        {
            commission = 131.25m + (principal * 0.0009m);
        }
    
        if (principal > 500000m)
        {
            commission = 206.25m + (principal * 0.000075m);
        }
    
        strPrincipal = principal.ToString("F");
        strCommission = commission.ToString("F");
        strTotalInvestment = (principal + commission).ToString("F");
    
        <form name="frmStocks" method="post">
            <table>
                <tr>
                    <td class="col-format boldness">Principal:</td>
                    <td><input type="text" name="txtPrincipal" value="@strPrincipal" /></td>
                </tr>
                <tr>
                    <td class="boldness">Commission:</td>
                    <td><input type="text" name="txtCommission" value="@strCommission" /></td>
                </tr>
                <tr>
                    <td class="boldness">Total Investment:</td>
                    <td><input type="text" name="txtTotalInvestment" value="@strTotalInvestment" /></td>
                </tr>
            </table>
        </form>
    }
  2. In the Solution Explorer, right-click StockBrokerCompany1 -> Add -> New Item...
  3. In the left list, expand Web and click Razor
  4. In the middle list, click Web Page (Razor v3)
  5. Change the name to Index
  6. Click Add
  7. Change the document as follows:
    <!DOCTYPE html>
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="~/Content/Site.css" />
    <title>Stock Broker Company</title>
    </head>
    <body>
    @{
        int numberOfShares = 0;
        decimal pricePerShare = 0.00m;
    
        if (IsPost)
        {
            numberOfShares = Request["txtNumberOfShares"].AsInt();
            pricePerShare = Request["txtPricePerShare"].AsDecimal();
        }
    }
    
    <div class="container">
        <h2>Stock Broker Company</h2>
    
        <form name="frmStocks" method="post">
            <table>
                <tr>
                    <td class="col-format boldness">Number of Shares:</td>
                    <td><input type="text" name="txtNumberOfShares" value="@numberOfShares" /></td>
                </tr>
                <tr>
                    <td class="col-second boldness">Price Per Share:</td>
                    <td><input type="text" name="txtPricePerShare" value="@pricePerShare" /></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="txtSubmit" class="col-format" value=Calculate /></td>
                </tr>
            </table>
        </form>
    
        @StocksProcessing.Trade(@numberOfShares, @pricePerShare)
    </div>
    </body>
    </html>
  8. To execute the application, on the main menu,, click Debug -> Start Without Debugging

    Introducing Boolean Conjunctions

  9. In the Number of Shares text box, type a natural number such as 64788
  10. In the Price Per Share text box, type a number such as 36.85:

    Introducing Boolean Conjunctions

  11. Click the Calculate button:

    Introducing Boolean Conjunctions

  12. Close the browser and return to your programming environment
  13. To make your code easier to read, it is a good idea to include each Boolean operation in its own parentheses.
    For a few examples, access the StocksProcessing.cshtml file and change its document as follows:

    @helper Trade(decimal numberOfShares, decimal pricePerShare) {
        decimal principal = 0.00m;
        decimal commission = 0.00m;
        string strCommission = "";
        string strPrincipal = "0.00";
        string strTotalInvestment = "";
    
        principal = numberOfShares * pricePerShare;
    
        if( (principal >= 0m) && (principal <= 2500m) )
        {
            commission = 26.25m + (principal * 0.0014m);
        }
    
        if( (principal > 2500m) && (principal <= 6000m) )
        {
            commission = 45.00m + (principal * 0.0054m);
        }
    
        if( (principal > 6000m) && (principal <= 20000m) )
        {
            commission = 60.00m + (principal * 0.0028m);
        }
    
        if( (principal > 20000m) && (principal <= 50000m) )
        {
            commission = 75.00m + (principal * 0.001875m);
        }
    
        if( (principal > 50000m) && (principal <= 500000m) )
        {
            commission = 131.25m + (principal * 0.0009m);
        }
    
        if (principal > 500000m)
        {
            commission = 206.25m + (principal * 0.000075m);
        }
    
        strPrincipal = principal.ToString("F");
        strCommission = commission.ToString("F");
        strTotalInvestment = (principal + commission).ToString("F");
    
        <form name="frmStocks" method="post">
            <table>
                <tr>
                    <td class="col-format boldness">Principal:</td>
                    <td><input type="text" name="txtPrincipal" value="@strPrincipal" /></td>
                </tr>
                <tr>
                    <td class="boldness">Commission:</td>
                    <td><input type="text" name="txtCommission" value="@strCommission" /></td>
                </tr>
                <tr>
                    <td class="boldness">Total Investment:</td>
                    <td><input type="text" name="txtTotalInvestment" value="@strTotalInvestment" /></td>
                </tr>
            </table>
        </form>
    }
  14. To execute the project, on the main menu, click Debug -> Start Without Debugging
  15. Enter some values in the text boxes above the button
  16. Click the Calculate button
  17. After testing the webpage, close the browser and return to your programming environment

Combining Various Conjunctions

Depending on your goal, if two conditions are not enough, you can create as many conjunctions as you want. The formula to follow is:

condition1 && condition2 && condition3 && . . . && condition_n

When the expression is checked, if any of the operations is false, the whole operation is false. The only time the whole operation is true is if all of the operations are true.

Of course, you can nest a Boolean condition inside another conditional statement.

Boolean Disjunctions

Introduction

A Boolean disjunction is a conditional statement where you combine more than one condition but only one of the conditions needs to be true for the whole operation to be true. This operation is performed using the Boolean "OR" operator represented as ||. The primary formula to follow is:

condition1 || condition2

The operation works as follows:

Practical LearningPractical Learning: Introducing Logical Disjunctions

  1. On the main menu of Microsoft Visual Studio, click File -> New -> Project...
  2. In the middle list, click ASP.NET Web Application (.NET Framework) and set the project Name to Chemistry07
  3. Click OK
  4. In the New ASP.NET Web Application, make sure Empty is selected and click OK
  5. In the Solution Explorer, right-click Chemistry07 -> Add -> Add ASP.NET Folder -> App_Code
  6. In the Solution Explorer, right-click App_Code -> Add -> Class...
  7. Replace the name with Element
  8. Click Add
  9. Change the code as follows:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace Chemistry07.App_Code
    {
        public enum Phase
        {
            Gas,
            Liquid,
            Solid,
            Unknown
        }
    
        public class Element
        {
            public string Symbol { get; set; } = "H";
            public string ElementName { get; set; } = "Hydrogen";
            public int AtomicNumber { get; set; } = 1;
            public decimal AtomicWeight { get; set; } = 1.008M;
            public Phase Phase { get; set; } = Phase.Gas;
    
            public Element()
            {
            }
    
            public Element(int number)
            {
                AtomicNumber = number;
            }
    
            public Element(string symbol)
            {
                Symbol = symbol;
            }
    
            public Element(int number, string symbol, string name, decimal mass)
            {
                Symbol = symbol;
                ElementName = name;
                AtomicWeight = mass;
                AtomicNumber = number;
            }
        }
    }
  10. In the Solution Explorer, right-click Chemistry07 -> Add -> New Folder
  11. Type Content and press Enter
  12. In the Solution Explorer, right-click Content -> Add -> New Item...
  13. In the left frame of the Add New Item dialog box, click Web and, in the middle frame, click Style Sheet
  14. Replace the name with Site
  15. Click Add
  16. Change the code as follows:
    body {
        margin: 0;
        background-color: #FFFFFF;
    }
    
    #top-banner {
        top: 0;
        width: 100%;
        height: 60px;
        position: fixed;
        background-color: #003366;
        border-bottom: 5px solid black;
    }
    
    .title-holder {
        top: 65px;
        width: 100%;
        height: 34px;
        position: fixed;
    }
    
    .container {
        width: 300px;
        margin: auto;
        padding-top: 10px;
    }
    
    .item-selection {
        width: 350px;
        margin: auto;
        padding-top: 120px;
    }
    
    #main-title {
        font-weight: 800;
        margin-top: 16px;
        font-size: 2.12em;
        text-align: center;
        color: yellow;
        font-family: Garamond, 'Times New Roman', Georgia, serif
    }
    
    #sub-title {
        color: navy;
        font-weight: 600;
        padding-top: 2px;
        font-size: 1.68em;
        text-align: center;
        font-family: Garamond, 'Times New Roman', Georgia, serif
    }
    
    .small-text { width:       40px;  }
    .emphasize  { font-weight: bold;  }
    .left-col   { width:       120px; }
  17. In the Solution Explorer, right-click App_Code -> Add -> New Item...
  18. In the left frame of the Add New Item dialog box, expand Web and click Razor
  19. In the middle list, click Helper (Razor v3)
  20. Replace the name with ElementsProcessing
  21. Click Add
  22. Create a helper as follows:
  23. @helper SelectElement(string symbol)
    {
        Chemistry07.App_Code.Element selected = new Chemistry07.App_Code.Element();
    
        Chemistry07.App_Code.Element h = new Chemistry07.App_Code.Element(1, "H", "Hydrogen", 1.008M) { Phase = Chemistry07.App_Code.Phase.Gas };
        Chemistry07.App_Code.Element he = new Chemistry07.App_Code.Element(2, "He", "Helium", 4.002602M) { Phase = Chemistry07.App_Code.Phase.Gas };
        Chemistry07.App_Code.Element li = new Chemistry07.App_Code.Element(3, "Li", "Lithium", 6.94M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element be = new Chemistry07.App_Code.Element(4, "Be", "Beryllium", 9.0121831M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element b = new Chemistry07.App_Code.Element(5, "B", "Boron", 10.81M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element c = new Chemistry07.App_Code.Element(name: "Carbon", mass: 12.011M, symbol: "C", number: 6) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element n = new Chemistry07.App_Code.Element(7);
        n.Symbol = "N";
        n.AtomicWeight = 14.007M;
        n.ElementName = "Nitrogen";
        n.Phase = Chemistry07.App_Code.Phase.Gas;
    
        Chemistry07.App_Code.Element o = new Chemistry07.App_Code.Element("O")
        {
            AtomicNumber = 8,
            ElementName = "Oxygen",
            AtomicWeight = 15.999M,
            Phase = Chemistry07.App_Code.Phase.Gas
        };
        Chemistry07.App_Code.Element f = new Chemistry07.App_Code.Element("F")
        {
            AtomicNumber = 9,
            ElementName = "Fluorine",
            AtomicWeight = 15.999M,
            Phase = Chemistry07.App_Code.Phase.Gas
        };
        Chemistry07.App_Code.Element ne = new Chemistry07.App_Code.Element("Ne")        
        {
            AtomicNumber = 10,
            ElementName = "Neon",
            AtomicWeight = 20.1797M,
            Phase = Chemistry07.App_Code.Phase.Gas
        };
        Chemistry07.App_Code.Element na = new Chemistry07.App_Code.Element(11, "Na", "Sodium", 22.98976928M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element mg = new Chemistry07.App_Code.Element(12, "Mg", "Magnesium", 24.305M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element al = new Chemistry07.App_Code.Element(13, "Al", "Aluminium", 26.9815385M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element si = new Chemistry07.App_Code.Element() { ElementName = "Silicon", AtomicWeight = 28.085M, Symbol = "Si", AtomicNumber = 14, Phase = Chemistry07.App_Code.Phase.Solid };
    
        if     ( symbol ==  "h" || symbol ==  "H") { selected =  h; }
        else if( symbol == "he" || symbol == "He" || symbol == "HE" || symbol == "hE") { selected = he; }
        else if( symbol == "li" || symbol == "Li" || symbol == "LI" || symbol == "lI") { selected = li; }
        else if( symbol == "be" || symbol == "Be" || symbol == "BE" || symbol == "bE") { selected = be; }
        else if( symbol ==  "b" || symbol ==  "B") { selected =  b; }
        else if( symbol ==  "c" || symbol ==  "C") { selected =  c; }
        else if( symbol ==  "n" || symbol ==  "N") { selected =  n; }
        else if( symbol ==  "o" || symbol ==  "O") { selected =  o; }
        else if( symbol ==  "F" || symbol ==  "f") { selected =  f; }
        else if( symbol == "ne" || symbol == "Ne" || symbol == "NE" || symbol == "nE") { selected = ne; }
        else if( symbol == "na" || symbol == "NA" || symbol == "Na" || symbol == "nA") { selected = na; }
        else if( symbol == "mg" || symbol == "Mg" || symbol == "MG" || symbol == "mG") { selected = mg; }
        else if( symbol == "al" || symbol == "Al" || symbol == "AL" || symbol == "aL") { selected = al; }
        else if( symbol == "si" || symbol == "Si" || symbol == "SI" || symbol == "sI") { selected = si; }
    
        <form name="frmChemistry" method="post">
            <table>
                <tr>
                    <td class="left-col emphasize">Atomic Number:</td>
                    <td><input type="text" name="txtAtomicNumber" value=@selected.AtomicNumber /></td>
                </tr>
                <tr>
                    <td class="emphasize">Symbol:</td>
                    <td><input type="text" name="txtSymbol" value=@selected.Symbol /></td>
                </tr>
                <tr>
                    <td class="emphasize">Element Name:</td>
                    <td><input type="text" name="txtElementName" value=@selected.ElementName /></td>
                </tr>
                <tr>
                    <td class="emphasize">Atomic Weight:</td>
                    <td><input type="text" name="txtAtomicWeight" value=@selected.AtomicWeight /></td>
                </tr>
                <tr>
                    <td class="emphasize">Phase:</td>
                    <td><input type="text" name="txtAtomicWeight" value=@selected.Phase /></td>
                </tr>
            </table>
        </form>
    }
  24. In the Solution Explorer, right-click Chemistry07 -> Add -> New Item...
  25. In the left list, expand Web and click Razor
  26. In the middle list, click Web Page (Razor v3)
  27. Change the name to Index
  28. Click Add
  29. Change the code as follows:
    <!DOCTYPE html>
    <html>
    <head>
        <title>Chemistry</title>
        <link rel="stylesheet" type="text/css" href="~/Content/Site.css" />
    </head>
    <body>
    @{
        string valueEntered = "";
    
        if(IsPost)
        {
            valueEntered = Request["txtValueEntered"];
        }
    }
    
    <div id="top-banner">
        <p id="main-title">Chemistry</p>
    </div>
    
    <div class="title-holder">
        <div id="sub-title"></div>
        <hr />
    </div>
    
    <div class="item-selection">
        <form name="frmChemistry" method="post">
            <table>
                <tr>
                    <td class="emphasize">Enter Element Symbol:</td>
                    <td>
                        <input type="text" name="txtValueEntered" class="small-text" value="@valueEntered" />
                        <input type="submit" name="btnFind" value="Find" style="width: 70px;" />
                    </td>
                </tr>
            </table>
        </form>
    
        @ElementsProcessing.SelectElement(@valueEntered)
    </div>
    </body>
    </html>
  30. To execute the project, on the main menu, click Debug -> Start Without Debugging:

    Introduction to Multiple Conditions

  31. In the top text box, type either a chemical symbol such as Al, B, Be, C, F, Fl, H, He, Li, Mg, N, Na, Ne, Si, etc

    Introduction to Conditional Disjunctions

  32. Click the Find button:

    Introduction to Boolean Disjunctions

  33. Close the browser and return to your programming environment
  34. As mentioned for the conjunction, it is a good idea to include each Boolean operation in its parentheses.
    Access the ElementsProcessing.cshtml file and change the code as follows:
    @helper SelectElement(string symbol)
    {
        Chemistry07.App_Code.Element selected = new Chemistry07.App_Code.Element();
    
        Chemistry07.App_Code.Element h = new Chemistry07.App_Code.Element(1, "H", "Hydrogen", 1.008M) { Phase = Chemistry07.App_Code.Phase.Gas };
        Chemistry07.App_Code.Element he = new Chemistry07.App_Code.Element(2, "He", "Helium", 4.002602M) { Phase = Chemistry07.App_Code.Phase.Gas };
        Chemistry07.App_Code.Element li = new Chemistry07.App_Code.Element(3, "Li", "Lithium", 6.94M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element be = new Chemistry07.App_Code.Element(4, "Be", "Beryllium", 9.0121831M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element b = new Chemistry07.App_Code.Element(5, "B", "Boron", 10.81M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element c = new Chemistry07.App_Code.Element(name: "Carbon", mass: 12.011M, symbol: "C", number: 6) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element n = new Chemistry07.App_Code.Element(7);
        n.Symbol = "N";
        n.AtomicWeight = 14.007M;
        n.ElementName = "Nitrogen";
        n.Phase = Chemistry07.App_Code.Phase.Gas;
    
        Chemistry07.App_Code.Element o = new Chemistry07.App_Code.Element("O")
        {
            AtomicNumber = 8,
            ElementName = "Oxygen",
            AtomicWeight = 15.999M,
            Phase = Chemistry07.App_Code.Phase.Gas
        };
        Chemistry07.App_Code.Element f = new Chemistry07.App_Code.Element("F")
        {
            AtomicNumber = 9,
            ElementName = "Fluorine",
            AtomicWeight = 15.999M,
            Phase = Chemistry07.App_Code.Phase.Gas
        };
        Chemistry07.App_Code.Element ne = new Chemistry07.App_Code.Element("Ne")        
        {
            AtomicNumber = 10,
            ElementName = "Neon",
            AtomicWeight = 20.1797M,
            Phase = Chemistry07.App_Code.Phase.Gas
        };
        Chemistry07.App_Code.Element na = new Chemistry07.App_Code.Element(11, "Na", "Sodium", 22.98976928M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element mg = new Chemistry07.App_Code.Element(12, "Mg", "Magnesium", 24.305M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element al = new Chemistry07.App_Code.Element(13, "Al", "Aluminium", 26.9815385M) { Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element si = new Chemistry07.App_Code.Element() { ElementName = "Silicon", AtomicWeight = 28.085M, Symbol = "Si", AtomicNumber = 14, Phase = Chemistry07.App_Code.Phase.Solid };
        Chemistry07.App_Code.Element  p = new Chemistry07.App_Code.Element() { ElementName = "Phosphorus", AtomicWeight = 30.973761998M, Symbol = "P", AtomicNumber = 15, Phase = Chemistry07.App_Code.Phase.Solid };
    
        if     ( (symbol ==  "h") || (symbol ==  "H") ) { selected =  h; }
        else if( (symbol == "he") || (symbol == "He") || (symbol == "HE") || (symbol == "hE") ) { selected = he; }
        else if( (symbol == "li") || (symbol == "Li") || (symbol == "LI") || (symbol == "lI") ) { selected = li; }
        else if( (symbol == "be") || (symbol == "Be") || (symbol == "BE") || (symbol == "bE") ) { selected = be; }
        else if( (symbol ==  "b") || (symbol ==  "B") ) { selected =  b; }
        else if( (symbol ==  "c") || (symbol ==  "C") ) { selected =  c; }
        else if( (symbol ==  "n") || (symbol ==  "N") ) { selected =  n; }
        else if( (symbol ==  "o") || (symbol ==  "O") ) { selected =  o; }
        else if( (symbol ==  "F") || (symbol ==  "f") ) { selected =  f; }
        else if( (symbol == "ne") || (symbol == "Ne") || (symbol == "NE") || (symbol == "nE") ) { selected = ne; }
        else if( (symbol == "na") || (symbol == "NA") || (symbol == "Na") || (symbol == "nA") ) { selected = na; }
        else if( (symbol == "mg") || (symbol == "Mg") || (symbol == "MG") || (symbol == "mG") ) { selected = mg; }
        else if( (symbol == "al") || (symbol == "Al") || (symbol == "AL") || (symbol == "aL") ) { selected = al; }
        else if( (symbol == "si") || (symbol == "Si") || (symbol == "SI") || (symbol == "sI") ) { selected = si; }
        else if( (symbol ==  "p") || (symbol ==  "P") ) { selected = p; }
    
        <form name="frmChemistry" method="post">
            <table>
                <tr>
                    <td class="left-col emphasize">Atomic Number:</td>
                    <td><input type="text" name="txtAtomicNumber" value=@selected.AtomicNumber /></td>
                </tr>
                <tr>
                    <td class="emphasize">Symbol:</td>
                    <td><input type="text" name="txtSymbol" value=@selected.Symbol /></td>
                </tr>
                <tr>
                    <td class="emphasize">Element Name:</td>
                    <td><input type="text" name="txtElementName" value=@selected.ElementName /></td>
                </tr>
                <tr>
                    <td class="emphasize">Atomic Weight:</td>
                    <td><input type="text" name="txtAtomicWeight" value=@selected.AtomicWeight /></td>
                </tr>
                <tr>
                    <td class="emphasize">Phase:</td>
                    <td><input type="text" name="txtAtomicWeight" value=@selected.Phase /></td>
                </tr>
            </table>
        </form>
    }

Combining Various Disjunctions

You can create a conditional statement that includes as many disjunctions as you want. The formula to follow is:

condition1 || condition2 || . . . || condition_n

The rule is the same: If any one of the individual operations is true, the whole operation is true. The whole operation is false only if all of the operations are false.

Combining Conjunctions and Disjunctions

Conjunctions and disjunctions can be used in the same expression. A conjunction (or disjunction) can be used to evaluate one sub-expression while a disjunction (or conjunction) can be used to evaluate another sub-expression.

Practical LearningPractical Learning: Ending the Lesson


Previous Copyright © 2001-2019, FunctionX Next