Question

I need help writing this program in C.

Armor Games CrazyMonkeyGames Max Games Palomar College堯Wolfram|Alpha M Gmail EaXGen Studios How About a Date? Dinner and Dancing with your Computer The purpose of this assignment is to acquaint you with the capability of a computer program to systematically explore a set of possibilities and deter mine the validity of input to the program. HPal-CSC112Spring 2017/ Lab Solutions 12-How about a datelcheckDatelnC Debuglche... elcome to my Date Checker Project Enter the date to test as: MM/DD/YYYY Pa CSC112 Spning 2017Lab Sclutions 12-How about a date checkDetelyC Debug checkDstel. elcome to my Date Checker Project nter the date to test as: MM/DD/YYYY 04/31/2017 It is a bad date Press any key to continue This is the user interface for this program The entire purpose of the program is to test a single string entry from the keyboard for the possibility that the entry is a valid date. Other than taking a single string from the user at the keyboard, and reporting the validity (as described below), the entire program should be written as a single function that returns true (1) if the date is valid and false (0) if it is not valid

media%2F55c%2F55cf4ca4-abfe-4265-b21b-62


(not C++)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

HI please find the answer

If you have any query please let me know first i will give solution

==============================================================

Your program in c

#include <stdio.h>

// function that return int

// and take a parameter month, date, and year

int valid_date( int mm,int dd, int yy) {

// if month is less than 1 and greater than 12

// return 0

if (mm < 1 || mm > 12) {

return 0;

}

  

// if date is less than 1 then return 0

if (dd < 1) {

return 0;

}

// declare variable days and initalize value to 31

int days = 31;

// if month is 2 i.e febuary

if (mm == 2) {

days = 28;

// check the leap year

// in this year the number of day in febuary is 29

if (yy % 400 == 0 || (yy % 4 == 0 && yy % 100 != 0)) {

days = 29;

}

}

// check the month which has 31 days in month

else if (mm == 4 || mm == 6 || mm == 9 || mm == 11) {

days = 30;

}

// if dd greater than days like 2, 29, 30, 31

// then return 0

if (dd > days) {

return 0;

}

// othewise return 1 if condition is true in all case

return 1;

}

// main function

int main(){

// declare a variable

int flag;

int dd,mm,yy;

// print the text

printf("Welcome to my Date Checker Project\n");

printf("Enter the date to test as : MM/DD/YYYY ");

// take the user input

scanf("%d/%d/%d",&mm,&dd,&yy);

// finally call and print the valid_date function by passing dd, mm and yy in it.

// this function return the value in 1 for valid date

// and 0 for not valid date

// and store in variable flag

flag=valid_date(mm, dd, yy);

// here check the flag

// if conditon is true then return valid

// otherwise false i.e not valid

if(flag==1)

{

printf("The date is valid" );

}

else

{

printf( "It is a bad date");

}

}

==================================================

Output

Test1

E\c++ Example\testingldateValidation.exe Welcome to my Date Checker Project Enter the date to test as MM/DD/YYYY 04/31/2017 It is a bad date Process exited after 11.29 seconds with return value 16 Press any key to continue .

Test2

test3

=============================================

If you have any query please let me know first i will give solution

Add a comment
Know the answer?
Add Answer to:
I need help writing this program in C. (not C++) Armor Games CrazyMonkeyGames Max Games Palomar...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help writing beginner C# program, I will make sure to provide feedback to whoever can...

    Need help writing beginner C# program, I will make sure to provide feedback to whoever can help me figure it out! No public or global variables should be used. You need to consider passing arguments between the methods according to the ways described in the lecture. i.e. all variables should be declared inside the methods and passed to other methods by value/ref/out as needed Description: We want to design a Date class to represent a date using three integer numbers...

  • C Program Question 1: Write a program 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...

  • Question 1: Write a program in C that reads a date from the keyboard and tests...

    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...

  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

  • please write C++ code to finish R0,R1,R2 Introduction In this assignment, you are going to develop...

    please write C++ code to finish R0,R1,R2 Introduction In this assignment, you are going to develop a "Schedule Book System that runs in the command line environment. The system stores the schedule of events input by user and allows users to add view or delete events. You can assume that the system can at most store 100 events Each group is required to write a Win32 Console Application program called ScheduleBook.cpp The requirements are listed below. RO When the program...

  • The assignment : Assignment You will be developing a speeding ticket fee calculator. This program will...

    The assignment : Assignment You will be developing a speeding ticket fee calculator. This program will ask for a ticket file, which is produced by a central police database, and your program will output to a file. Furthermore, your program will restrict the output to the starting and ending dates given by the user. The ticket fee is calculated using four multipliers, depending on the type of road the ticket was issued: Interstate multiplier: 5.2252 Highway multiplier: 9.4412 Residential multiplier:...

  • Write a program called RentalRate.java which reads in a date of birth, today’s date and a...

    Write a program called RentalRate.java which reads in a date of birth, today’s date and a male/female designation from the user, and will then determine the basic daily and weekly rates for rental of an economy class car. Rental rate classes are: Best rate (male drivers, age 33–65 and female drivers, age 30-62)--$40.00per day, $200.00 per week Risk rate 1 (female drivers, age 25–29)–Best rate plus $10.00 per day or best rate plus $55.00 per week. Risk rate 2 (male...

  • I need help with this assignment in C++, please! *** The instructions and programming style detai...

    I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...

  • I need help with my coding for C++! The goal of this is to calculate the...

    I need help with my coding for C++! The goal of this is to calculate the total cost of a product by combining the products price and the amount of tax, then display it to the user. The numbers we have to test out is 100 for the price and 8.25 for the percentage. When I test is out, the formula works but it isn't rounding the 108.25 to 108.3, which is the total price we are supposed to display...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT