Question

In: Computer Science

Write a program that checks whether or not a date entered in by the user is...

Write a program that checks whether or not a date entered in by the user is valid. Display the date and say if it is valid. If it is not valid explain why.

  • The input may be in the format mm/dd/yyyy, m/d/yyyy, mm/d/yyyy, or m/dd/yyyy.
  • A valid month (mm) must be from 1 to 12
  • A valid day (dd) must be from 1 to the appropriate number of days in the month
    • April, June, September, and November have 30 days
    • February has 28 except for leap years, then it has 29
    • The rest have 31 days
    • Leap years are years that are divisible by 4 BUT not divisible by 100 unless it is also divisible by 400

I don't need the coding. Just help with the questions 1 and 2.

  1. Include a flow chart in your proposed solution section
  2. Write the equivalent Boolean expression !(a>b)&&!(b==c) which doesn’t use the NOT operator (!). Assume that a, b, and c are integers.

Solutions

Expert Solution

Flowchart For Date Validity

Refer to below image and i am explaining the numbering mentioned there block by block what is being done

1. We are informing user to enter a date in the format of dd/mm/yyyy and take input from user and store value in three variables named as dd,mm,yy.

2. We are checking yy valid or not by if(yy>=1900 && yy<=9999)

3.If 2 is not true we are printing month is invalid

4. Here we are checking date is between 1 to 31 and months having 31 days along with that i.e Jan, Mar,May ,july ,Aug ,Oct ,Dec

like this

 if((dd>=1 && dd<=31) && (mm==1 || mm==3 || mm==5 || mm==7 || mm==8 || mm==10 || mm==12))

5. Here we are checking date is between 1 to 30 and months having 30 days along with that i.e April ,June ,Sept,November.

((dd>=1 && dd<=30) && (mm==4 || mm==6 || mm==9 || mm==11))

6. A special for date of february is done i.e data is between 1 to 28 and month is february or mm==2;

((dd>=1 && dd<=28) && (mm==2))

7. Checking Leap Year And If it is a leap yera then February has 29 days so check for both

(dd==29 && mm==2 && (yy%400==0 ||(yy%4==0 && yy%100!=0)))

8. If all of the 4 5 6 7 block dissatisfy then we print date is invalid.

9. If any of the block 4 5 6 7 block satisfy the condition then we print date is valid

10 . Put each last block to end .

Flowchart Ends

Q2

Boolean Expression is


Related Solutions

PYTHON Write a program that accepts a range of input from the user and checks whether...
PYTHON Write a program that accepts a range of input from the user and checks whether the input data is sorted or not. If the data series is already sorted your program should print “True” or should print “False” otherwise. You should not use any sort function for this program. Input: How many numbers you want to input: 3 # user input 3 Input the number: 5 Input the number: 2 Input the number: 7 Output: False
Write a program that asks the user for an integer. The program checks and prints to...
Write a program that asks the user for an integer. The program checks and prints to the screen whether the number is prime or not. For example, if user enters 17, the program should print “17 is prime”; if the user enters 20, the program should print “20 is not prime”. please do it with a “ while Loop”, Thanks..
How would I write a program for C++ that checks if an entered string is an...
How would I write a program for C++ that checks if an entered string is an accepted polynomial and if it is, outputs its big-Oh notation? Accepted polynomials can have 3 terms minimum and no decimals in the exponents.
In PYTHON: Write a program that asks for a password from a user and checks if...
In PYTHON: Write a program that asks for a password from a user and checks if it satisfies the conditions: Contains at least one lowercase letter (a-z). Contains at least one uppercase letter (A-Z). Contains at least one digit (0-9). Minimum length 6 characters. Contains no spaces. If the password is valid, then the program prints “password accepted”. Otherwise, it keeps asking for more passwords from the user until a valid password is obtained. Hint: You might like to check...
Write a C++ program that finds the minimum number entered by the user .The user is...
Write a C++ program that finds the minimum number entered by the user .The user is allowed to enter negative numbers 0, or positive numbers. The program should be controlled with a loop statement. Break statements is not allowed to break from loop. After each number inputted by the user, The program will prompt user if they need to enter another number. User should enter either Y for yes or N for no. Make Sure the user enters either Y...
Write a program that asks the user for an angle, entered in radians. The program should...
Write a program that asks the user for an angle, entered in radians. The program should then display the sine, cosine, and tangent of the angle. (Use the sin, cos, and tan library functions to determine these values.) The output should be displayed in fixed-point notation, rounded to four decimal places of precision Take your previous Angle Calculator program and modify it to do a table of trig values. The columns will be: Degrees, Sine, Cosine, Tangent,. And the rows...
How to write a C++ program that lets the user enter a string and checks if...
How to write a C++ program that lets the user enter a string and checks if it is an accepted polynomial. Accepted polynomials need to have one term per degree, no parentheses, spaces ignored.
Write a pro-active password checker that checks to make sure that a user entered password meets...
Write a pro-active password checker that checks to make sure that a user entered password meets certain requirements. You must implement a simple program that prompts the user for two String values, a password and the same password again for confirmation. For the purposes of this lab, a legal password must have all of the following properties: ▪ Length of at least 8 characters ▪ Starts with a lower case letter ▪ Ends with a numerical digit ▪ Has one...
*Please write code in C++* Write a program to verify the validity of the user entered...
*Please write code in C++* Write a program to verify the validity of the user entered email address.   if email is valid : output the stating that given email is valid. ex: "The email [email protected] is valid" else : output the statement that the email is invalid and list all the violations ex:  "The email sarahwinchester.com is invalid" * @ symbol * Missing Domain name The program should keep validating emails until user enter 'q' Upload your source code. ex: main.cpp
C programming Get a number from the user and write a program that checks to see...
C programming Get a number from the user and write a program that checks to see if the inputted number is equal to x*x+x and x must be greater than 0. For example, if the user inputs 12. The program should check to see if 12 = x*x+x. In this case it is true because 3*3+3 = 12.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT