Monday, August 15, 2022
Envato Elements
HomeCodingDart Program To Get The Name Of The Day

Dart Program To Get The Name Of The Day

Day Name Based On Day Number

Dart program to get the name of the day by entering the number of the day using Switch Case
For Example:-

Day = 1Output = Sunday
Day = 2Output = Monday
Day = 3Output = Tuesday
Day = 4Output = Wednesday
Day = 5Output = Thursday
Day = 6Output = Friday
Day = 7Output = Saturday

To run dart program open www.dartpad.dev

Program

void main() {
  int day = 2; //Enter day number
  
  switch (day){
    case 1: { //Case For Day 1
      print("Sunday"); //Statement
    }
      break;
      
    case 2: { //Case For Day 2
      print ("Monday"); //Statement
    }
      break;
      
    case 3: { //Case For Day 3
      print ("Tuesday"); //Statement
    }
      break;
      
    case 4: { //Case For Day 4
      print ("Wednesday"); //Statement
    }
      break;
      
    case 5: { //Case For Day 5
      print ("Thursday"); //Statement
    }
      break;
      
    case 6: { //Case For Day 6
      print ("Friday"); //Statement
    }
      break;
      
    case 7: { //Case For Day 7
      print ("Saturday"); //Statement
    }
      break;
      
    default: {  //Default Case
      print ("Invalid Day Number"); //Statement
    }
      break;
  }
}

OUTPUT:

Monday
RELATED ARTICLES
- Advertisment - Domains + Hosting + Security

Most Popular

Recent Comments