Question #256944

We want to replicate the Covid-19 Vaccination notification system. The user input the date of a person who has received the first dose of vaccine they should receive the text message telling them the next date for the 2nd dose. Vaccine Name Waiting Period for 2nd Dose Pfizer ‘F’ 24 Moderna ‘M’ 25 Sinopharm ‘S’ 15 Sinovac ‘V’ 18 Pakvac ‘P’ 21 AstraZeneca ‘A’ Not Required Sample Input Enter the Day of the first dose of vaccination: 12 Enter the Month of the first dose of vaccination: 7 Enter the Year of the first dose of vaccination: 2021 Enter the vaccination Name: P

Expert's answer

#include <stdio.h>

int nextDate(int n, int d) { return (n + d) % 31; }

int main() 
{
  int date, month, year;  
  char vaccine;

  printf("Enter the Day of the first dose of vaccination: ");
  scanf("%d", &date);

  printf("Enter the Month of the first dose of vaccination: ");
  scanf("%d", &month);

  printf("Enter the Year of the first dose of vaccination: ");
  scanf("%d", &year);

  printf("Enter the vaccination Name: ");
  scanf("%s", &vaccine);

  switch(vaccine) {
    case 'F': {
      printf("Next date of vaccine: %d %d %d", nextDate(date, 24), month, year);
      break;
    }
    case 'M': {
      printf("Next date of vaccine: %d %d %d", nextDate(date, 25), month, year);
      break;
    }
    case 'S': {
      printf("Next date of vaccine: %d %d %d", nextDate(date, 15), month, year);
      break;
    }
    case 'V': {
      printf("Next date of vaccine: %d %d %d", nextDate(date, 18), month, year);
      break;
    }
    case 'P': {
      printf("Next date of vaccine: %d %d %d", nextDate(date, 21), month, year);
      break;
    }
    case 'S': {
      printf("Not Required");
      break;
    }
    default: {
      printf("Invalid type of vaccine!!!");
      break;
    }
  }
  return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS