Question 1: Write a program in C that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format:
mm/dd/yyyy
Note that there is no space in the above format. A date in this format must be entered in one line.
A valid month value mm must be from 01 to 12 ( January is 01). The day value dd must be from 01 to a value that is appropriate for the given month. September, April, June, and November each have 30 days. February has 28 days except for leap years when it has 29. The remaining months all have 31 days each. For the sake of simplicity assume the year is a leap year.
Note: It is an error if the user enters any other character in place of: /.
Hints:
Your program can read a date with one scanf and 3 variables.
Answer
#include <stdio.h>
int main()
{
//variable declaration
int dd,mm,yy;
//display message
printf("Enter date (mm/dd/yyyy): ");
scanf("%d/%d/%d",&mm,&dd,&yy);
//check year value
if(yy<1000 || yy>9999)
{
printf("The year value is not valid.");
return 0;
}
//check month value
if(mm<1 || mm>12)
{
printf("Month is not valid.");
return 0;
}
//check day value
if((dd>=1 && dd<=31) && (mm==1 || mm==3 ||
mm==5 || mm==7 || mm==8 || mm==10 || mm==12))
{
printf("The date: %d/%d/%d is valid", mm, dd, yy);
}
else if((dd>=1 && dd<=30) && (mm==4 || mm==6
|| mm==9 || mm==11))
{
printf("The date: %d/%d/%d is valid", mm, dd, yy);
}
else if((dd>=1 && dd<=29) && (mm==2))
{
printf("The date: %d/%d/%d is valid", mm, dd, yy);
}
else
{
printf("Day is not valid");
}
return 0;
}
OUTPUT:


Question 1: Write a program in C that reads a date from the keyboard and tests...
C Program Question 1: Write a program that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...
Write a program that reads a string from keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12 (January is 1). The day value dd must be 1 from to a value that is appropriate...
Write a Java console application that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is NOT valid. The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12 (January is 1). You can use: String monthPart = inputDate.substring(0, 2); int month =...
JAVA CODE Beginner. please use if, else if or switch statements, but don't use arrays, please Write a program that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12...
PYTHON Build a regular expressions based on informal specifications to match specified patterns. Use a compiled regular expression in a Python program where appropriate. Use Python's text processing str methods to generate a string format converter. create a date format converter. Your program will convert a date in the format “mm/dd/yyyy” to the format “month day, year”. Specify the required input format: mm/dd/yyyy Use a regular expression to validate the user input date format. If the format is incorrect raise...
Python
3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018
3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018
Write a program that reads a string from the keyboard and tests whether it contains a valid time. Display the time as described below if it is valid, otherwise display a message as described below. The input date should have the format hh:mm:ss (where hh = hour, mm = minutes and ss = seconds in a 24 hour clock, for example 23:47:55). Here are the input errors (exceptions) that your program should detect and deal with: Receive the input from...
IN PYTHON, Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the form April 12, 2017. Hint: Get the "mm" from the user entered date "mm/dd/yyyy", then convert the "mm" into a month number. You may use an list month_list = ['January', 'February','March','April', 'May','June', 'July','August', 'September', 'October', 'November', 'December']. Use the month number you got from "mm" to get the month name.
Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018 I am asking for help in basic python please
Write a C++ program accepts a three-integer date in the following formats: mm/dd/yyyy or mm-dd-yyyy. Write a Boolean function that validates the date. Note: account for leap years. After testing with single dates and verifying the algorithm works, set your program up to accept a file called dates.dat. Read the dates into your program and output bad dates to a file called bad_dates.dat.