Question

In: Computer Science

When $type is 'VIP', set $rate at 0.20. When $type is not 'VIP' and if $quantity...

When $type is 'VIP', set $rate at 0.20. When $type is not 'VIP' and if $quantity is greater than or equal to 10, set $rate to 0.1; otherwise, set $rate to 0.0. Assume that the values for $type and $quantity are known. in the following write just one PHP if statement (not several separate if statements) to cover the above situations.

Solutions

Expert Solution

Dear Student ,

As per requirement submitted above kindly find below solution.

Question :

Answer :

$rate=($type=="VIP")?$rate=0.20:(($type!="VIP" && $quantity>=10)?$rate=0.1:$rate=0.0);

Explanation :

  • This demonstration is uisng ternary operator in PHP to test the condition

Demonstration :

<?php

    //declaring variables

    $type="sVIP";

    $quantity=20;

    //using ternary operator

    $rate=($type=="VIP")?$rate=0.20:(($type!="VIP" && $quantity>=10)?$rate=0.1:$rate=0.0);

    //print value of $rate

     echo "rate :".$rate;

?>

==================================

Screen when $type =VIP :

Screen when $type =sVIP and qunatity is less than 10 :

Screen when $type =sVIP and qunatity is greater than 10 :

NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

How to set the Price and Quantity that maximize the profit in every type of market?...
How to set the Price and Quantity that maximize the profit in every type of market? Compare how to set them by using graph under monopoly and perfect competition!
A set of questions that really measures Type A behavior when the theoretical concept desired is...
A set of questions that really measures Type A behavior when the theoretical concept desired is life stress has: A. Low predictive validity B. Low concurrent validity C. Low construct validity
If the tax elasticity of labor supply is 0.20, by what percentage will the quantity of labor supplied increase in response to
If the tax elasticity of labor supply is 0.20, by what percentage will the quantity of labor supplied increase in response to Instructions: In part b, enter your response as a percentage rounded to one decimal place. a. A $500 per person income tax rebate check?A 2% increaseA 1.5% increaseNo increaseA 4.5% increaseb. A 6 percent reduction in marginal tax rates?       %
I. What would happen to the nominal interest rate and quantity of money when the Fed...
I. What would happen to the nominal interest rate and quantity of money when the Fed decides to buy bonds through open market operations (OMO)?  Answer this using at least 100 words. II. What if the Fed lowers the discount rate? What would happen to the nominal interest rate and quantity of money? Answer this using at least 100 words.
a ) Set n=20 p=0.20. What is the mean and standard deviation according to the Central...
a ) Set n=20 p=0.20. What is the mean and standard deviation according to the Central Theorem for proportions? What is the mean and standard deviation? b) Set n=100 p=0.20. What is the mean and standard deviation according to the Central Limit Theorem for Proportions? What is the mean and standard deviation? In which of the above cases do you get a Normal distribution (with mean 0.2 and standard deviation equal to sqrt(0.2 (1-0.2) / n) )? Why ?
What is the present value of the following set of cash flows when the discount rate...
What is the present value of the following set of cash flows when the discount rate is 11% p.a. compounded monthly?  (Rounded to the nearest dollar). Year 1 $260 Year 2 $330 Year 3 $800 Year 4 $760 $1,605 $1,660 $1,565 $1,560 None of the above What is the future value of $6,000 invested for 8 years at an annually compounded interest rate of 11.5% p.a.? (Rounded to the nearest dollar). $14,980 $14,220 $14,333 $14,560 None of the above Melbourne Ltd...
D22: When given any data set: A.) How do we determine the type of model to...
D22: When given any data set: A.) How do we determine the type of model to use? (Linear, quadratic, exponential, logarithmic)? B.) When fitting an exponential model to data, what is important to know about the input values? C.) Provide an example to illustrate this idea.
Marcel Co. is growing quickly. Dividends are expected to grow at a rate of 0.20 for...
Marcel Co. is growing quickly. Dividends are expected to grow at a rate of 0.20 for the next 4 years, with the growth rate falling off to a constant 0.01 thereafter. If the required return is 0.14 and the company just paid a $1.95 dividend, what is the current share price? Answer with 2 decimals (e.g. 45.45).
A playground merry-go-round is set spinning at 0.20 rev/s and then released. It slows to rest...
A playground merry-go-round is set spinning at 0.20 rev/s and then released. It slows to rest in 25 s. (a) Find the average angular acceleration of the merry-go-round during this time. (b) Assuming now that the angular acceleration is constant, how many turns does it make as it comes to rest?
Looking back on 4 March 2008 when the interest rate was set at 7.25% by RBA...
Looking back on 4 March 2008 when the interest rate was set at 7.25% by RBA (Reserve Bank Australia), however since then RBA gradually reduced the interest rate to its lowest 1% on 3 July 2019. Present an overview on the expectations or motivations behind such interest rate cut by RBA? (summary) [Note: In the early 1990s the interest rate was 17.5%, you don’t need to go back such distant past, your analysis should focus between 2008 to 2019] Talk...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT