Question

In: Computer Science

var selectedColor = document.getElementById("colorChoice").value; var selectedStyle = document.getElementById("style").value; var selectedSize = document.getElementById("size").value; var orderMessage = "Your...

var selectedColor = document.getElementById("colorChoice").value;
var selectedStyle = document.getElementById("style").value;
var selectedSize = document.getElementById("size").value;

var orderMessage = "Your order is: Color = " + selectedColor
+ "; Style = " + selectedStyle
+ "; Size = " + selectedSize+"\n";

if (selectedStyle==="Long-sleeve")
//Add code to calculate the price and concatenate it to the orderMessage
//For example, "The order is: Color = gray; Style=T-Shirt; Size = XL \nThe price is $12"
//If the style and size are not available, then concatenate the message that it is not available instead of a price.
// -- Notice: the color, style, and style is already stored variables for you
// a t-shirt in any size is $9
// a long-sleeve t-shirt in adult sizes is $18
// a long-sleeve t-shirt is youth sizes is not available
// a tech shirt is is $12 except 2XL and 3XL which are $16.


alert(orderMessage);
//Next change this alert to write the order status to the HTML page.
}

Solutions

Expert Solution

   var selectedColor = document.getElementById("colorChoice").value;
   var selectedStyle = document.getElementById("style").value;
   var selectedSize = document.getElementById("size").value;

   var orderMessage = "Your order is: Color = " + selectedColor
   + "; Style = " + selectedStyle
   + "; Size = " + selectedSize+"<br>";
  
   // if selectedStyle is long-sleeve (case insensitive comparison)

/// toLowerCase method converts the string to lower case so the comparison can be done without taking case into account
   if (selectedStyle.toLowerCase()==="long-sleeve")
   {  
       // if selectedSize is adult (case insensitive comparison)
       if(selectedSize.toLowerCase() === "adult")
       {
           orderMessage += "The price is $18.";
       }else if(selectedSize.toLowerCase() === "youth") // if selectedSize is youth (case insensitive comparison)
       {
           orderMessage += "It is not available.";
       }  
   }else if(selectedStyle.toLowerCase() === "tech shirt") // if selectedStyle is tech shirt (case insensitive comparison)
   {
       // if selectedSize is 2xl or 3xl (case insensitive comparison)
       if(selectedSize.toLowerCase() === "2xl" || selectedSize.toLowerCase() === "3xl")
       {
           orderMessage += "The price is $16.";
       }else // any other size for tech shirt
           orderMessage += "The price is $12.";
   }else if(selectedStyle.toLowerCase() === "t-shirt") // if selectedStyle is t-shirt (case insensitive comparison)
       orderMessage += "The price is $9.";
   else   // if any other item then its not available  
       orderMessage += "It is not available.";
  
   //Add code to calculate the price and concatenate it to the orderMessage
   //For example, "The order is: Color = gray; Style=T-Shirt; Size = XL \nThe price is $12"
   //If the style and size are not available, then concatenate the message that it is not available instead of a price.
   // -- Notice: the color, style, and style is already stored variables for you
   // a t-shirt in any size is $9
   // a long-sleeve t-shirt in adult sizes is $18
   // a long-sleeve t-shirt is youth sizes is not available
   // a tech shirt is is $12 except 2XL and 3XL which are $16.


   //alert(orderMessage);
   //Next change this alert to write the order status to the HTML page.
  
   //Suppose result is the id of the HTML element where we need to display the order details
   document.getElementById("result").innerHTML = orderMessage;
}


Related Solutions

Illustrate the difference between the value-at-risk (VaR) and conditional value-at-risk (C-VaR) measures
Illustrate the difference between the value-at-risk (VaR) and conditional value-at-risk (C-VaR) measures
Prove Var(|X|) <= Var(X)
Prove Var(|X|) <= Var(X)
For the following style rules, what is the font size of the h1 heading in pixels?...
For the following style rules, what is the font size of the h1 heading in pixels? body {font-size: 16px;} body > article {font-size: 0.75em;} body > article > h1 {font-size: 1.5em;} 16px; 12px; 18px; 18.25px;
If a Normal distribution is assumed for the possible future outcomes, the Value at Risk (VaR)...
If a Normal distribution is assumed for the possible future outcomes, the Value at Risk (VaR) is fairly straightforward and simple to calculate if the mean and standard deviation are known. True False A fairly accurate estimate of the Value at Risk (VaR) can be determined by using the generally accepted assumption that daily returns of the stock market as measured by the S&P 500 Index are consistent with a Normal distribution. True False The Value at Risk (VaR) tells...
Javascript Problem: List Reverse Given a list: var list = { value: 1, next: { value:...
Javascript Problem: List Reverse Given a list: var list = { value: 1, next: { value: 2, next: { value: 3, next: null } } }; Reverse the order of the list so that it looks like: var list = { value: 3, next: { value: 2, next: { value: 1, next: null } } }; Use the following shell if needed: //assignment1.js function reverseList(list) { // your code here ... return reversedList; } Example Test Case(s): Arguments: { value:...
Social style: Suppose that you have amiable style, what characteristics of your style best define you?...
Social style: Suppose that you have amiable style, what characteristics of your style best define you? What challenges have you identified in interacting with other styles? What particular challenges does your style present in leading others? What strategies can you use to best accomplish tasks, given your own style and the different styles you around you? What different tactics might you use to best 'connect' with others to help them buy-in to your position?
Value at Risk (VaR) is an attempt to provide a single number for senor management summarizing...
Value at Risk (VaR) is an attempt to provide a single number for senor management summarizing the total risk in a portfolio of financial assets. It has become widely used by corporate treasurers and fund managers as well as by financial institutions. A company currently has $5 million invested in commodity X and $3 million invested in commodity Y. The daily sigma of commodity X is 1 percent, the daily sigma of commodity Y is 1.5 percent, and the coefficient...
.p2(2) VaR (Value at Risk) is defined as ///////////////////////////////////// In words: The maximum loss over a...
.p2(2) VaR (Value at Risk) is defined as ///////////////////////////////////// In words: The maximum loss over a predetermined period with a confidence interval. formula : VaR=position * z * sigma where position : the value of your portfolio z : depends on the confidence interval =norm.inv(0.01,0,1)=-2.326347874 # for 99% =norm.inv(0.05,0,1)=-1.644853627 # for 95% sigma : the period standard deviation Assume that we have 100 shares of IBM stocks, 200 shares of Wal-Mart and 300 shares of Citi Group (ticker is C)....
Describe some advantages and disadvantages of Value at Risk (VaR) as a risk measure relative to...
Describe some advantages and disadvantages of Value at Risk (VaR) as a risk measure relative to other risk measures
VAR Measures the potential maximum 1-day loss on the value of positions of an MNC that...
VAR Measures the potential maximum 1-day loss on the value of positions of an MNC that is exposed to exchange rate movements. Basically, it goes to compute how much is the maximum possible loss of MNC going to be if exchange rates move against the firm position. In Calculating the Value at Risk (VAR), what is the implication of underestimating volatility of exchange rates? ( Please respond in a complete and explanatory way ) Answer should have 100 words minimum
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT