help with javascript

Feb 11, 2017

Provide the following for Lab 2: an algorithm and working program code.
Create a program which displays the current season for each month of the year: Winter, Spring, Summer, or
Fall. Use the following information to write the program:
• Use a counter variable named month. The month variable will have a range of 1-12. The 1-12 range
represents the months of the year. Begin with 1 for January, end with 12 for December. Stop
processing when the month value is 12.
• Increment the month variable in one month increments (1, 2, 3, etc.) only.
• The season to display is determined by the following rules:
o "Winter" if the month variable's value is 12, 1, or 2.
o "Spring" if the month variable's value is in the range of 3-5.
o "Summer" if the month variable's value is in the range of 6-8
o "Fall" if the month variable's value is in the range of 9-11.
• The correct season should be displayed for each month based on the preceding rules.
o The same greeting will be displayed repeatedly while the condition is true. i.e. while the current
month value is within a particular range of months (see the output example below).
• Do not display the month number or month name, only display the season the month falls in.
You will need to use the following language elements:
1. A numeric variable called month which should be initialized to a starting value of 1 (1 represents
January).
2. A while loop to process the months as long as it is within the range January (1) through December (12).
a. You will need to increment the month variable by one for each iteration of the while loop. The month
variable represents the current month of the year.
3. An if/else if statement to determine the season to display based on the current value of the month variable.
4. Use the document.write function for output. Remember, each season will be displayed multiple times for a
month range (Winter, Spring, Summer, Fall). The output should be as follows:

Winter

Winter 

Spring

Spring

Spring

Summer

Summer

Summer

Fall

Fall

Fall

Winter

 

 

1 Reply

This discussion is closed. You can start a new discussion or contact Articulate Support.