Day Calculation Background - Many times one needs to do calculations on dates. Programs like Excel use the number of days since 1/1/1970 when doing these calculations. We don't know enough C++ to completely do this calculation, yet, but we can make a start. Problem - You will prompt a user for a month, a day and a year. You will then tell the user how many days since January 1 of that year the input date is. For example if the user inputs a 3 for the month, a 2 for the day, and 2000 for the year the program outputs the number of days as being 62. Note 2000 is a leap year. Therefore you must test to see if a year is a leap year when doing this problem. The three rules which the Gregorian calendar uses to determine leap year are as follows: 1. Years divisible by four are leap years, unless... 2. Years also divisible by 100 are not leap years, except...** 3. Years divisible by 400 are leap years. ** ** Combining rules 2 & 3: Centennial years that are not divisible by 400 are not leap years. **Another way of looking at the definition of a leap year: Leap years fall on any year that either can be evenly divided by 400 or evenly divided by 4 and not evenly divided by 100. Therefore the years 1900, and 2100 are NOT leap years. Method - Use if - else statements to decide: 1. How many days to add given the month 2. Whether to add an additional day for leap year. 3. Don't forget to add in the days for the current date within a month Ex. if the user inputs month = 4, day = 22, year = 1995 Since 1995 is not a leap year add 90 days (total for January, February, and March) then to that add 22 for the number of days in April for a total of 112 days. Output - Organize your prompts, and output in a neat orderly fashion. Print a statement telling whether the year is a leap year and another statement about the number of days since January 1 of that year has past. Turn In – Your source code and 3 valid examples (pick ones that are/are not leap years) showing that your program works.

Question

Lab #3 – Day Calculation
Background - Many times one needs to do calculations on dates. Programs like Excel use the number of days since 1/1/1970 when doing these calculations. We don't know enough C++ to completely do this calculation, yet, but we can make a start.
Problem - You will prompt a user for a month, a day and a year. You will then tell the user how many days since January 1 of that year the input date is.
For example if the user inputs a 3 for the month, a 2 for the day, and 2000 for the year the program outputs the number of days as being 62. Note 2000 is a leap year. Therefore you must test to see if a year is a leap year when doing this problem.
The three rules which the Gregorian calendar uses to determine leap year are as follows:
1. Years divisible by four are leap years, unless...
2. Years also divisible by 100 are not leap years, except...**
3. Years divisible by 400 are leap years. **
** Combining rules 2 & 3: Centennial years that are not divisible by 400 are not leap years.
**Another way of looking at the definition of a leap year:
Leap years fall on any year that either can be evenly divided by 400 or evenly divided by 4 and not evenly divided by 100.
Therefore the years 1900, and 2100 are NOT leap years.
Method - Use if - else statements to decide:
1. How many days to add given the month
2. Whether to add an additional day for leap year.
3. Don't forget to add in the days for the current date within a month
Ex. if the user inputs month = 4, day = 22, year = 1995
Since 1995 is not a leap year add 90 days (total for January, February, and March) then to that add 22 for the number of days in April for a total of 112 days.
Output - Organize your prompts, and output in a neat orderly fashion. Print a statement telling whether the year is a leap year and another statement about the number of days since January 1 of that year has past.
Turn In – Your source code and 3 valid examples (pick ones that are/are not leap years) showing that your program works.

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Let L = {aibjck | i, j, k ≥ 0 and if i = 1 then j=k}. a. Show that L is not regular using closure p...

A: Introduction A regular language can be conveyed with the help of a regular expression. They are ack...

Q: Hi, I need to solve this problem with C++ programming language. Thank you.

A: Formula to convert the pounds to tons: We know that the 1 ton =2000 pounds Therefore, the pounds co...

Q: Suppose the RAM for a certain computer has 256M words, where each word is 16 bits long. a. What is t...

A: Click to see the answer

Q: How do I get the commas to show up in my python results? The expected results are what my code needs...

A: Hey! Your code is good. You have just done one mistake in printing the final output.   The line prin...

Q: What are the main problems related to fragmented files?

A: Fragmentation: Actually, Fragmentation is also known as splitting and a method of reproduction.

Q: In C++ create the following program Your program will read in "game scores" from the user. Each scor...

A: The program efffectively uses 2D array to stro game scores of two teams. when option 1 is entered, I...

Q: write a program that produces the following output:  in your program, substitute ??? with your own ...

A: Program:-(python 3) #taking input name name=input() length=len(name) print('+' + '-'*length + '+') p...

Q: How Edmodo is used by learners to add value to learning by collaborating and networking?

A: Edmodo brings everyone in the education community together to help learners succeed. It lets learne...

Q: Next, you will create the grid styles for the March Specials page. Go to the Grid Styles section and...

A: CSS GRID LAYOUT: In CSS, The grid is defined as a set of intersecting horizontal and vertical column...

Q: What are some security concerns inherit wired, wireless and mobile networking?

A: Wired Network Threats: Comparing wireless with cable Internet threats, Cable networks are more guard...

Q: Write a program that informs a user of their meal charge. Create a variable to hold the meal charge ...

A: Since the language is not mentioned therefore writing the code in C : #include<stdio.h>int mai...

Q: consider the udp header 05 31 00 oe 00 1a e3 11. what is the length of the data?

A: udp header 05 31 00 oe 00 1a e3 11 First 16 bits = Source Port Next 16 bits = Destination Port Next ...

Q: What are some troubleshooting methods and network commands you may utilize or have utilized for your...

A: Troubleshooting method for the simple network are: - Check from settings if the Wi-Fi switch is on ...

Q: Question No.4: Process Synchronization. Consider the classical synchronization problem of dining phi...

A: Step 1:- Introduction:- Dining-Philosophers Problem:- In this problem, there are N philosophers and ...

Q: Here is my question that I have from my algorithms' class.  Modify the linear-time an an algorithm f...

A: Step 1:- Note:-There is no programming language is mention therefore i am writing the program in c++...

Q: Creat a class reversit and Write a function called reversit () that reverses a C-string (an array of...

A: C++ code to reverse the string 1)Create the function reversit() where you are passing the user input...

Q: Encode the following valurs into the floating-point format discussed in the text. indicate the occur...

A: a. (2*4+1)/4 = 9/4 = 2.25 b. (5*4+1)/4= 21/4 = 5.25

Q: Calculate the CPI if the clock cycle time is 0.333ns

A: CPI is cycles per instruction The average instruction that is executed will take a number of cycles ...

Q: Using informal arguments: Write a function polynomial which implements a polynomial function of arbi...

A: Click to see the answer

Q: Write a program that accepts numbers from the user and counts the positive and negative numbers. The...

A: Below is the required code in C++ language. Program Approach: Including header files and using a n...

Q: Write answer with explaination

A: From the above C code, we are supposed to tell how many times "Hello, World" will be printed.

Q: For the project you chose as a good fit for waterfall, describe the following roles: project manager...

A: Agile project roles Project manager is key person to steer project. Project manager manages the tea...

Q: You must use Python to solve the following problem. You will need to run the codes and print both th...

A: This problem is a case of a Quadratic equation having two roots. This can be solved using the quadra...

Q: In one project, it is required to define cubes whose compressive strength limits 20-30 mpa. Accordin...

A: Program approach: Define the program name. Declare do loop between limits 20-30. Prints results and...

Q: Let M be a FSM with n states. Let p and q be distinguishable states of M and let x be a shortest str...

A: A finite deterministic automation M (transducer, Mealy machine, n M (transducer, Mealy machine, fini...

Q: Convert each decimal number to octal 45.8 12478.3

A: PROCEDURE: To convert a decimal number to octal form following steps are used: If the number is le...

Q: Because % is a wildcard character, how can the LIKE operator search for a literal percent sign (%) i...

A: Wildcards are normally used in conjunction with the LIKE comparison operators or with the NOT LIKE c...

Q: What is the output of this program? #include int main) char str[5]="ABC"; cout << str[3]: cout << s...

A: EXPLANATION: - The character of size 5 is declared and initialized as: - char str[5] = "ABC"; The ...

Q: How must the "building blocks" of data communication networks such as switches, routers and cabling ...

A: Step 1:-   Introduction:-   A Computer network defines a network which is made up of two or more com...

Q: Hello, I need to solve this problem with C++ programming language using Visual Studio. Thank you.

A: Roots of a quadratic equation : The roots of a quadratic equation, can be calculated by using the b...

Q: Please help me with the solution:   MySQL */ CREATE TABLE AGENT ( AGENT_CODE int, AGENT_LNAME varcha...

A: Hey! This is pretty intuitive.   All you need to do is create a database then the respective tables ...

Q: How Can I Write a python program that displays a table of inches from 1-12 and equivalent lengths in...

A: Introduction of Program This python program displays a table of length in inches and equivalent leng...

Q: Suppose we have an array of signed shorts (each short value is 2-byte long) S with a base address in...

A: Step 1:- It is given that there is an array whose store the integer value and the size of each integ...

Q: Find a counterexample to these universally quantified statements, where the do- main for all variabl...

A: Step 1:- Introduction:- A predicate is defined as a sentence that contains a finite number of variab...

Q: Explain types of system architecture

A: System architecture A system architecture is a way of defining the system structure, behavior, and ...

Q: I needed the FiveOnly program in Java just like the Programming Challenge #13 in the Starting Out Wi...

A: Program will take the file name entered and stores into a variable. Opens the specified file using n...

Q: You have been hired by PetPals Veterinary Clinic to modify its Bill Calculator application.  Upon re...

A: Explanation: The double data type is used to store the real or decimal number with double precision...

Q: Assigning variables using python software

A: # Creating the integer variable a and assigns it with 10a = 10 # Creating the string variable b and ...

Q: An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hour...

A: PROGRAM: #Getting input for hourly wage hourlyWage = int(input("Enter the hourly wage: "))   #Gettin...

Q: Create a style rule for the section element with the id "sub" that displays that element as a grid c...

A: CSS GRID LAYOUT: In CSS, The grid is defined as a set of intersecting horizontal and vertical column...

Q: Write the relational algebra formula to apply an INTERSECT relational operator to the tables shown i...

A: INTERSECT: - The rows appearing is both BOOTH and MACHINE table is yielded in this case as a result...

Q: Hello, I have a few questions in regards to SQL Server. It was answered on the website before, but w...

A: Stored procedures: A procedure is a collection of procedural and SQL statements. A procedure may h...

Q: C++ Program   Complete the given Car class with set, get,and display functions as well as a construc...

A: Programming instructions: Include necessary header files. Declare the required variables. Create a ...

Q: if a flow chart or psuedocode contains a conditional test, the results may vary, why?

A: Flowchart: Flowchart is basically a visual representation of the flow and states of any program. In...

Q: Assume these definitions:int n1 = 4, n2 = 5, n3 = 30;double d1 = 3.0, d2 = 10.0;Please enter the num...

A: Generally, inputs are provided as data values and then calculations are performed on these data valu...

Q: Which of the following will cause an interrupt for the CPU? -Memory Reference to the Kernel Space -S...

A: The answer is all of the above An interrupt is a signal emitted by hardware or software when a proc...