Question

Make this if statement into a switch statement in Powershell $Month = Read-Host "What month were...

Make this if statement into a switch statement in Powershell

$Month = Read-Host "What month were you born in? Input a number 1-12"

if($month -eq 1) {
echo "You were born in: January"
}elseif ($Month -eq 2) {
echo "You were born in: Febuary"
}elseif ($Month -eq 3) {
echo "You were born in: March"
}elseif ($Month -eq 4) {
echo "You were born in: April"
}elseif ($Month -eq 5) {
echo "You were born in: May"
}elseif ($Month -eq 6) {
echo "You were born in: June"
}elseif ($Month -eq 7) {
echo "You were born in: July"
}elseif ($Month -eq 8) {
echo "You were born in: August"
}elseif ($Month -eq 9) {
echo "You were born in: September"
}elseif ($Month -eq 10) {
echo "You were born in: October"
}elseif ($Month -eq 11) {
echo "You were born in: November"
}elseif ($Month -eq 12) {
echo "You were born in: December"
}esle {"There are only 12 months in the calendar....please choose between 1-12"}

Homework Answers

Answer #1

Hi ,

Please find the code -

$Month = Read-Host "What month were you born in? Input a number 1-12"
switch($Month)
{
        1 {"You were born in: January"}
    2 {"You were born in: Febuary"}
    3 {"You were born in: March"}
    4 {"You were born in: April"}
    5 {"You were born in: May"}
        6 {"You were born in: June"}
        7 {"You were born in: July"}
        8 {"You were born in: August"}
        9 {"You were born in: September"}
        10 {"You were born in: October"}
        11 {"You were born in: November"}
        12 {"You were born in: December"}
        Default {
        "There are only 12 months in the calendar....please choose between 1-12"
    }
}

output -

Thank You.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(C++ Program) Create an enum (enumeration) for the Months of the Year. Use a Switch statement...
(C++ Program) Create an enum (enumeration) for the Months of the Year. Use a Switch statement Selection structure to output the Various International/Domestic Holidays for each month as following: Jan - New Years Day Feb - Valentines Day March - St. Patrick's Day April - Earth Day May - MayPole Day June - Juneteenth July - Eid-al-Adha August - National Mahjong Day September - Talk Like a Pirate Day October - United Nations Day November - International Computer Security Day...
The table below shows the closing monthly stock prices for IBM and Amazon. Calculate the simple...
The table below shows the closing monthly stock prices for IBM and Amazon. Calculate the simple three-month moving average for each month for both companies. (Input all amounts as positive values. Do not round intermediate calculations. Round your answers to 2 decimal places.) IBM AMZN January $ 175.04 $ 613.41 February 176.89 623.12 March 191.47 574.07 April 207.78 547.70 May 192.37 510.30 June 208.63 495.58 July 234.49 606.39 August 204.16 536.91 September 220.55 512.70 October 214.59 601.73 November 196.34 591.56...
Problem 8-3 Simple Moving Averages (LO4, CFA1) The table below shows the closing monthly stock prices...
Problem 8-3 Simple Moving Averages (LO4, CFA1) The table below shows the closing monthly stock prices for IBM and Amazon. Calculate the simple three-month moving average for each month for both companies. (Input all amounts as positive values. Do not round intermediate calculations. Round your answers to 2 decimal places.) IBM AMZN January $ 174.44 $ 611.96 February 176.49 622.04 March 190.21 575.48 April 206.45 547.30 May 192.85 512.38 June 208.17 496.78 July 233.16 606.09 August 205.39 537.36 September 220.07...
Incidents By Month For 2018 January 5,400 MEAN MEDIAN MODE February 4,930 5,181 5,216 5260 March...
Incidents By Month For 2018 January 5,400 MEAN MEDIAN MODE February 4,930 5,181 5,216 5260 March 5,330 April 5,042 May 5,143 June 5,172 July 5,260 August 5,260 September 5,339 October 5,283 November 4,909 December 5,109 Is it a standard distribution, why or why not?
The monthly sales for Yazici Batteries, Inc., were as follows: MONTH SALES January 20 February 21...
The monthly sales for Yazici Batteries, Inc., were as follows: MONTH SALES January 20 February 21 March 15 April 14 May 13 June 16 July 17 August 18 September 20 October 20 November 21 December 23 Plot the monthly sales data. Forecast January sales using each of the following: Naive method. A 3-month moving average. A 6-month weighted average using .1, .1, .1, .2, .2, and .3, with the heaviest weights applied to the most recent months. Exponential smoothing using...
Lubriderm Corporation has the following budgeted unit sales for the next six-month period: Month Unit Sales...
Lubriderm Corporation has the following budgeted unit sales for the next six-month period: Month Unit Sales June 130,000 July 100,000 August 160,000 September 200,000 October 140,000 November 180,000 There were 26,000 units of finished goods in inventory at the beginning of June. Plans are to have an inventory of finished products that equal 20% of the unit sales for the next month. Five pounds of materials are required for each unit produced. Each pound of material costs $20. Raw material...
Demand for stereo headphones and MP3 players for joggers has caused Nina Industries to grow almost...
Demand for stereo headphones and MP3 players for joggers has caused Nina Industries to grow almost 50 percent over the past year. The number of joggers continues to expand, so Nina expects demand for headsets to also expand, because, as yet, no safety laws have been passed to prevent joggers from wearing them. Demand for the players for last year was as follows: MONTH DEMAND (UNITS) January 4,210 February 4,310 March 4,010 April 4,410 May 5,010 June 4,710 July 5,310...
The table below shows the closing monthly stock prices for IBM and Amazon. Calculate the simple...
The table below shows the closing monthly stock prices for IBM and Amazon. Calculate the simple three-month moving average for each month for both companies. (Input all amounts as positive values. Do not round intermediate calculations. Round your answers to 2 decimal places.) IBM AMZN January $ 173.84 $ 610.51 February 176.09 620.96 March 188.95 576.89 April 205.12 546.90 May 193.33 514.46 June 207.71 497.98 July 231.83 605.79 August 206.62 537.81 September 219.59 513.22 October 214.35 599.71 November 195.44 593.30...
KING KARS You begin the year with a cash balance of $50,000, and the minimum cash...
KING KARS You begin the year with a cash balance of $50,000, and the minimum cash balance desired must be $50,000 every month. Prepare a cash ow summary and external financing summary as noted in Excel spreadsheet. JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER GIVEN: MONTHLY NET CASH GAIN OR LOSS $5,000 $(30,000) $20,000 $(35,000) $25,000 $(10,000) $25,000 $25,000 $(30,000) $15,000 $15,000 $25,000 JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER...
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1....
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January - December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs to adjust the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT