Write a program to determine the day of the week a person was born given his or her birth date. Following are the steps you should use to find the day of the week corresponding to any date in this century.

A) Divide the last 2 digits of the birth year by 4. Put the quotient (ignoring the remainder) in Total. For example, if the person was born in 1983, divide 83 by 4 and store 20 in Total.

Add the last two digits of the birth year to the Total.

C) Add the day portion to the birth date to Total.

D)Using the following table, find the "Month Number" and add it to the total.

January = 1, February = 4, March = 4, April = 0, May = 2, June = 5, July = 0, August = 3, September = 6, October = 1, November = 4, and December = 6.

E) If the year is a leap year and, if the month you are working with is either January or February, then subtract 1 from the Total.

F) Find the remainder when Total is divided by 7. Look up the remainder in the following table to determine the day of the week the person was born. Note that you should not use this procedure if the person's year of birth is earlier than 1900.

1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, and 0 = Saturday.

A typical line of data is

5 - 15 78

where the first entry (5-15) represents the month and day (May 15) and the second entry (78) represents the birth year. An appropriate error message should be printed if a person's year of birth is before 1900.

This would be a HUGE help for me... if you have a web site, I will link to it to my site, www.Internapse.com

Please post the program here or you can e-mail it to me at [email protected]

THANK YOU SO MUCH

~Scott

It looks like you're new here. If you want to get involved, click one of these buttons!

- 140.8K All Categories
- 103.6K Programming Languages
- 6.4K Assembler Developer
- 401 Assembly Code Share
- 239 Getting started in assembly
- 4.6K x86 Assembly
- 1.9K Basic
- 97 Qbasic
- 39.9K C and C++
- 5.6K Beginner C/C++
- 330 C/C++ on Linux/Unix
- 450 C/C++ Windows API
- 522 C++ Builder
- 253 C++ Game Development
- 3.3K C++ MFC
- 103 C++.NET
- 404 Visual C++
- 2.9K C#
- 7.9K Delphi and Kylix
- 334 Advanced Delphi
- 360 Delphi beginners
- 4 Haskell
- 9.7K Java
- 56 Enterprise JavaBeans
- 1.3K Java Beginners
- 304 Java Server Pages
- 4.1K Pascal
- 1.3K Perl
- 11 Perl 6
- 2K PHP
- 546 Python
- 37 Ruby
- 4.4K VB.NET
- 258 Advanced VB.Net
- 1.6K VBA
- 20.8K Visual Basic
- 767 Access databases and VB
- 831 Advance Visual Basic
- 1.2K Beginner VB
- 2.6K Game programming
- 315 Console programming
- 90 DirectX Game dev
- 1 Minecraft
- 112 Newbie Game Programmers
- 2 Oculus Rift
- 9K Applications
- 1.8K Computer Graphics
- 279 3D Graphics
- 129 DirectX
- 125 OpenGL
- 740 Computer Hardware
- 9 Cooling & Overclocking
- 3.4K Database & SQL
- 1.1K Access
- 91 ADO Programming
- 288 MySQL
- 358 Oracle
- 440 SQL-Server
- 535 Electronics development
- 1.6K Matlab
- 628 Sound & Music
- 25 DirectSound
- 257 XML Development
- 3.3K Classifieds
- 199 Co-operative Projects
- 198 For sale
- 190 FreeLance Software City
- 1.9K Jobs Available
- 603 Jobs Wanted
- 209 Wanted
- 2.9K Microsoft .NET
- 1.8K ASP.NET
- 1.1K .NET General
- 22 .NET WEB-Services
- 129 .NET WinForms
- 14 .NET XML
- 50 ADO.NET
- 142 C# & VB.NET School Support
- 3.4K Miscellaneous
- 4 Join the Team
- 354 Comments on this site
- 69 Computer Emulators
- 2.1K General programming
- 187 New programming languages
- 621 Off topic board
- 200 Mobile & Wireless
- 72 Android
- 126 Palm Pilot
- 338 Multimedia
- 154 Demo programming
- 184 MP3 programming
- 0 Bash scripts
- 27 Cloud Computing
- 1 Witsbits Go Cloud
- 53 FreeBSD
- 1.7K LINUX programming
- 1 Awk scripting
- 332 Linux Support
- 0 Sed scripting
- 370 MS-DOS
- 0 Shell scripting
- 321 Windows CE & Pocket PC
- 4.1K Windows programming
- 177 COM/DCOM
- 61 Networking And Security
- 17 Windows 2003 Server
- 6 Windows Vista
- 176 Windows XP
- 939 Software Development
- 416 Algorithms
- 68 Object Orientation
- 24 RUP & UML
- 91 Project Management
- 95 Quality & Testing
- 268 Security
- 63 Evil Scripting
- 81 Hacking
- 7.7K WEB-Development
- 1.8K Active Server Pages
- 61 AJAX
- 4 Bootstrap Themes
- 55 CGI Development
- 28 ColdFusion
- 224 Flash development
- 1.4K HTML & WEB-Design
- 1.4K Internet Development
- 131 Mobile Internet & Messaging
- 211 Wireless development
- 2.2K JavaScript
- 37 JQuery
- 304 WEB Servers
- 153 Apache
- 79 IIS
- 150 WEB-Services / SOAP

## Comments

:

: Write a program to determine the day of the week a person was born given his or her birth date. Following are the steps you should use to find the day of the week corresponding to any date in this century.

: A) Divide the last 2 digits of the birth year by 4. Put the quotient (ignoring the remainder) in Total. For example, if the person was born in 1983, divide 83 by 4 and store 20 in Total.

:

: Add the last two digits of the birth year to the Total.

:

: C) Add the day portion to the birth date to Total.

:

: D)Using the following table, find the "Month Number" and add it to the total.

: January = 1, February = 4, March = 4, April = 0, May = 2, June = 5, July = 0, August = 3, September = 6, October = 1, November = 4, and December = 6.

:

: E) If the year is a leap year and, if the month you are working with is either January or February, then subtract 1 from the Total.

:

: F) Find the remainder when Total is divided by 7. Look up the remainder in the following table to determine the day of the week the person was born. Note that you should not use this procedure if the person's year of birth is earlier than 1900.

: 1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, and 0 = Saturday.

: A typical line of data is

:

: 5 - 15 78

:

: where the first entry (5-15) represents the month and day (May 15) and the second entry (78) represents the birth year. An appropriate error message should be printed if a person's year of birth is before 1900.

That all sounds straight-forward, where's the problem?

: :

: : Write a program to determine the day of the week a person was born given his or her birth date. Following are the steps you should use to find the day of the week corresponding to any date in this century.

: : A) Divide the last 2 digits of the birth year by 4. Put the quotient (ignoring the remainder) in Total. For example, if the person was born in 1983, divide 83 by 4 and store 20 in Total.

: :

: : Add the last two digits of the birth year to the Total.

: :

: : C) Add the day portion to the birth date to Total.

: :

: : D)Using the following table, find the "Month Number" and add it to the total.

: : January = 1, February = 4, March = 4, April = 0, May = 2, June = 5, July = 0, August = 3, September = 6, October = 1, November = 4, and December = 6.

: :

: : E) If the year is a leap year and, if the month you are working with is either January or February, then subtract 1 from the Total.

: :

: : F) Find the remainder when Total is divided by 7. Look up the remainder in the following table to determine the day of the week the person was born. Note that you should not use this procedure if the person's year of birth is earlier than 1900.

: : 1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, and 0 = Saturday.

: : A typical line of data is

: :

: : 5 - 15 78

: :

: : where the first entry (5-15) represents the month and day (May 15) and the second entry (78) represents the birth year. An appropriate error message should be printed if a person's year of birth is before 1900.

:

:

:

: That all sounds straight-forward, where's the problem?

:

------------------------------

That is the problem, to write a program that determines the person's day of the week, the person was born using those above instructions. It tells you what needs to happen, using IF and THEN statements, but I'm pretty new to programming, and not sure where to start for the problem.

Well I would start at the top and work my way down. Try doing A, and once it's working try doing B, once it's working try doing C, etc.. If you get stuck on one of the steps, post the code you're trying and maybe someone can spot the problem. So that you know if you're doing it right, here's the values you should have at the end of each step based on the date Sept. 20, 1980

A) 20

100

C) 120

D) 126

E) 126

F) 0

Sept. 20, 1980 was a Saturday

On part E, it says If the year is a leap year and, if the month you are working with is either January or February, then subtract 1 from the Total.

How would you find out that the year is a leap year? Such as in 1987? When it says and, does it mean that the month has to be January or February and also a leap year? or just if the month is January or February?

Does this mean that if the month is March through December and a leap year, nothing happens?

:

: How would you find out that the year is a leap year? Such as in 1987? When it says and, does it mean that the month has to be January or February and also a leap year? or just if the month is January or February?

:

: Does this mean that if the month is March through December and a leap year, nothing happens?

Im not 100% on the rules of leap year, but I think it's:

[code]

LeapYear := (Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0))

[/code]

If you search on google Im sure you'll be able to find if that's right or not. That needs a 4 digit year, so just "80" wont work, you need to use "1980"

And yes it means only subtract 1 if it is a leap year AND January or February. So using my example, 1980 was a leap year but I did not subtract 1 because the month was September.

Here is my finished Birthday Program

[Code]

PROGRAM Ch5Prb16;

USES crt;

{Scott Kondor, Period 2}

{This program will, given the birth date of a person, determine the day of

the week the person was born.}

VAR

Month, Answer, DayofWeek, Message : String;

Day, Year, BYear, BDay, MonthNum, Total, Total2 : integer;

LeapYear : Boolean;

BEGIN {Main Program}

{Input}

clrscr;

write ('Please enter the month you were born with the first letter ');

writeln ('as a CAPITAL letter. For example, January with a capital J.');

readln (Month);

writeln ('Please enter the the day of the month you were born.');

readln (Day);

writeln ('Please enter the year you were born.');

readln (Year);

{Calculations}

BYear := ((Year - 1900) DIV 4);

BDay := Year - 1900;

IF (Month = 'July') OR (Month = 'April') THEN

MonthNum := 0;

IF (Month = 'January') OR (Month = 'October') THEN

MonthNum := 1;

IF (Month = 'May') THEN

MonthNum := 2;

IF (Month = 'August') THEN

MonthNum := 3;

IF (Month = 'February') OR (Month = 'March') OR (Month = 'November') THEN

MonthNum := 4;

IF (Month = 'June') THEN

MonthNum := 5;

IF (Month = 'September') OR (Month = 'December') THEN

MonthNum := 6;

LeapYear := (Year MOD 4 = 0) AND ((Year MOD 100 <> 0) OR (Year MOD 400 = 0));

Total := BYear + BDay + Day + MonthNum;

IF ((LeapYear) AND (Month = 'February') OR (Month = 'January')) THEN

Total := Total - 1

ELSE

Total := Total;

Total2 := Total MOD 7;

IF Total2 = 1 THEN

DayofWeek := 'Sunday';

IF Total2 = 2 THEN

DayofWeek := 'Monday';

IF Total2 = 3 THEN

DayofWeek := 'Tuesday';

IF Total2 = 4 THEN

DayofWeek := 'Wednesday';

IF Total2 = 5 THEN

DayofWeek := 'Thursday';

IF Total2 = 6 THEN

DayofWeek := 'Friday';

IF Total2 = 0 THEN

DayofWeek := 'Saturday';

{Output}

clrscr;

writeln ('Birthday Program':44);

writeln ('----------------':44);

writeln; writeln;

IF Year < 1900 THEN

writeln ('I''m sorry, but your birthday is before 1900 and can''t be computed')

ELSE

writeln ('Your birthday ':30, Month,' ', Day,' ',Year,' is a ',DayofWeek,'.');

writeln;

writeln ('Thank you for using Scott''s Birthday Program':57);

readln;

END.

[/Code]