Class Schedule in C Homework Sample

Write a program that allows a user to enter a date between January and May and display the class schedule. Between the 25th and 29th March there is Spring Break. If the date is before 21st January it should display class has not yet started, and if the date is not mentioned in the class schedule it should display no class, nothing associated. For more C programming assignment help contact us for a quote.

Solution:

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
char mon[][10] = {“Jan”, “Feb”,
“Mar”, “Apr”,”May”};
int getMonth(char * month)
{

for(int i = 0;i<5;i++)
{
if(strcmp(mon[i] , month) == 0)
{
return i;
}
}
return -1 ;
}
int main()
{
char month[10];
int day;
scanf(“%s %d”, month, &day);
int month_num = getMonth(month);
if(month_num == -1)
{

puts(“No class, nothing associated”);
return 1;
}
switch (month_num)
{
case 0:
if(day < 21)
{
puts(“Wrong input, Semester not started yet”);
return 1;
}
switch (day)
{
case 21:
puts(“Semester First day of Classes”);
break;
case 22:
puts(“Introduction”);
break;
case 29:
puts(“Input and output in c , Data types”);
break;

default:
puts(“No class, nothing associated”);

break;
}
break;

case 1 ://Feb
switch(day)
{
case 5:
puts(“Variables, Values, Constants, Expressions”);
break ;
case 12:
puts(“More Exercises”);
break ;
case 19:
puts(“Algorithms, Boolean Values/Expressions Simple If”);
break ;
case 26:
puts(“Cascaded If, While loops, Switch statements”);
break ;
default:
puts(“No class, nothing associated”);

break;
}
break;

case 2:
switch(day)
{
case 5:
puts(“Exam1 [L1 to L6] + Project Introduction”);
break ;
case 12:
puts(“While and for Loops”);
break ;
case 19:
puts(“more Loops exercises”);
break ;

default:
if(day>=25 && day <= 29)
{

puts(“Spring Break”);
}
else {
puts(“No class, nothing associated”);
}
break;
}
break;
case 3:
switch(day)
{
case 2:
puts(“Nested Loops”);
break ;

case 9:
puts(“Exam 2 [L2 to L9]”);
break ;

case 16:
puts(“1D arrays”);
break ;

case 23:
puts(“Functions”);
break ;

case 30:
puts(“Arrays and functions more exercises”);
break ;

default:
puts(“No class, nothing associated”);
break;
}
break;

default:
if(month_num == 4 && day == 7)
{
puts(“Final Exam [Comprehensive]”);
}
else
puts(“No class, nothing associated”);

break;
}
return 0;
}