Write a C++ program that, given a person's birth date, computes and displays the day of the week the person was born. Th

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a C++ program that, given a person's birth date, computes and displays the day of the week the person was born. Th

Post by answerhappygod »

Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 1
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 1 (32.21 KiB) Viewed 63 times
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 2
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 2 (36.96 KiB) Viewed 63 times
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 3
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 3 (46.13 KiB) Viewed 63 times
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 4
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 4 (25.7 KiB) Viewed 63 times
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 5
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 5 (59.67 KiB) Viewed 63 times
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 6
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 6 (49.89 KiB) Viewed 63 times
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 7
Write A C Program That Given A Person S Birth Date Computes And Displays The Day Of The Week The Person Was Born Th 7 (89.33 KiB) Viewed 63 times
Write a C++ program that, given a person's birth date, computes and displays the day of the week the person was born. The description of the assignment is given below. Check for User inputs Your program should first check for user inputs. If the date entered is not a valid, send out an error message as shown in the example below: 1 37 2001> Incorrect Data If the date entered is valid, proceed to compute for the corresponding week of the day. Determine the day of the week one was born We use the formula called: Zeller's Rule to compute the day of the week for a person's birthday. The following formula is named Zeller's Rule after a Reverend Zeller. Here's the formula: f=d+(13m-1)/5+D+D/4+C/4-2C. P
Determine the day of the week one was born We use the formula called: Zeller's Rule to compute the day of the week for a person's birthday. The following formula is named Zeller's Rule after a Reverend Zeller. Here's the formula: f=d+(13m-1)/5+D+D/4+C/4-2C. declare all variables to be of integer type Steps 1. d is the day of the month. Let's use January 29, 2064 as an example. For this date, d = 29. 2. m is the month number. Months have to be counted in a special way for Zeller's Rule: March is 1. April is 2, and so on to January is 11, and February is 12. (This makes the formula simpler, because on leap years February 29 is counted as the last day of the year.) Because of this rule, January and February are always counted as the 11th and 12th months of the previous year. In our example, m= 11. (use multi-way if statement to compute the m value based on month) 3. If the original birth month is January or February: subtract 1 from the year value. In our case, birth month
3. If the original birth month is January or February: subtract 1 from the year value. In our case, birth month is January, therefore, modified year = year-1= 2064-1=2063. For all other birthday months, do not subtract 1 from the birth year, i.e., modified year = year. 4. D is the last two digits of the modified year. In this example, D=modified year % 100 = 2063%100=63. 5. C stands for century: it's the first two digits of the modified year value. In our case, C = 2063/100= 20. Now let's substitute our example numbers into the formula: f=d+ [(13m-1)/5]+D+ [D/4]+[C/4] - 2C = 29+ [(1311-1)/5]+63+ [63/4] + [20/4] - 220 = 29+ [28] +63 + [15] + [5]-40=29 +28+63 +15+5-40 = 100. This f number modulo 7 gives the day of week: (0:Sunday, 1:Monday, 2:Tuesday, 3:Wednesday, 4:Thursday, 5:Friday, 6:Saturday). Use multi-way if statement to display the day of the week. For example, 100 % 7= 2. Therefore Jan 29th, 2064 is on Tuesday. If the remainder is negative, add 7 to the remainder. Given an example data as 6 15 1988 115 2001
1 37 2001 5 12 2005 219 2000 2 29 2001 The program should output the following (the format of the output should be exactly as shown below): 6 15 1988 => Wednesday 115 2001 => Monday 1 37 2001> Incorrect Data 5 12 2005 => Thursday 219 2000=>Saturday 2 29 2001-> Incorrect Data 4
#include <iostream> // for ein, cout, endl, etc using namespace std; int main() ( int day; // a person's day of birth from user input. int month; // a person's month of birth from user input. int year, // a person's year of birth from user input. // declare other variables here // This loop will read one birthday at a time til the end // of the data file is reached // For each birthday read: // (1) check whether the birthday is valid // if it is not valid, display the message // (2) if it is valid compute and display the day of the week while (cin >> month >> day >>year) { cout << month <<""<< day <<"" << year << "=>"; // Check for birthday validity // if the birthday is valid, compute and display its corresponding weekday // end while return 0;
3. For each program module (function), describe/define each variable used in that module. Variable names must be descriptive. Separate variable definitions from variable descriptions. Use the following form for this description: variable declared; // variable description in English sentence(s) Properly indent all code according to descriptions given in "Indent C Programs" (http://www.cs.arizona.edu/-mccann/indent_c.html). You must be consistent in the number of spaces used for indentation. . To improve readability, use a moderate amount of white space, i.e., insert blank lines between blocks of code, and between different modules/functions. Comments need to be written for each logically related block of code. This include a while or for loop, a if decision statement, a switch statement, a group of statements that compute a value, a block of code that read in user data, a group of statements that displays output, etc. 4. For each user defined function, comments need to be written above the function describing: o What does this function do? o What are the expected input values? o What are the expected return values? 5. Programs with syntax error, have compilation error, will not be graded.
Program Development Documentation Style Correctness Description If program has compilation error. If program terminates with run time error. Main Comment Block contains: (due date (1), author name(1), course- section #(1), and program description (2)). Comments have been added to each group of logically related statements above each decision statement (if, if/else) above each loop statement above one or more sequence statements that together accomplish a cohesive task Variable: . . Meaningful variable names are used unless specified by the program description Indentation and white spaces are used to make the program easier to read. . Variable naming convention is followed No global variable is used HALAY All the decision statements are indented properly. All the repetition statements (loops) are indented properly Blank lines are used in front of each block of logically rela statements Program solves the assigned problem using methods described in the program description: Check for user input (5) Week day calculation (20) - negative f value is properly handled in the program (5) Program produces the correct output when tested using different user input. Correct error message was produced if user input is incorrect (10) tan-Correct week day is displayed for valid user input (40)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply