Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 2.21 KB

Day 3 - Control Structures Assignment.md

File metadata and controls

35 lines (27 loc) · 2.21 KB

Day 3: Control Structures

Tasks/Activities:

Activity 1: If-Else Statements

  • Task 1: Write a program to check if a number is positive, negative, or zero, and log the result to the console.
  • Task 2: Write a program to check if a person is eligible to vote (age >= 18) and log the result to the console.

Activity 2: Nested If-Else Statements

  • Task 3: Write a program to find the largest of three numbers using nested if-else statements.

Activity 3: Switch Case

  • Task 4: Write a program that uses a switch case to determine the day of the week based on a number (1-7) and log the day name to the console.
  • Task 5: Write a program that uses a switch case to assign a grade ('A', 'B', 'C', 'D', 'F') based on a score and log the grade to the console.

Activity 4: Conditional (Ternary) Operator

  • Task 6: Write a program that uses the ternary operator to check if a number is even or odd and log the result to the console.

Activity 5: Combining Conditions

  • Task 7: Write a program to check if a year is a leap year using multiple conditions (divisible by 4, but not 100 unless also divisible by 400) and log the result to the console.

Feature Request:

  1. Number Check Script: Write a script that checks if a number is positive, negative, or zero using if-else statements and logs the result.
  2. Voting Eligibility Script: Create a script to check if a person is eligible to vote based on their age and log the result.
  3. Day of the Week Script: Write a script that uses a switch case to determine the day of the week based on a number (1-7) and log the day name.
  4. Grade Assignment Script: Create a script that uses a switch case to assign a grade based on a score and logs the grade.
  5. Leap Year Check Script: Write a script that checks if a year is a leap year using multiple conditions and logs the result.

Achievement:

By the end of these activities, students will:

  • Implement and understand basic if-else control flow.
  • Use nested if-else statements to handle multiple conditions.
  • Utilize switch cases for control flow based on specific values.
  • Apply the ternary operator for concise condition checking.
  • Combine multiple conditions to solve more complex problems.