SlideShare a Scribd company logo
1 of 20
1
Summer 2017
Assignment 4 IndividualAssignment - Due June27,
2017
(400 Points)
Part I (200 points)
In this assignment, you will be performing some important data-
processing
operations, specifically sorting a large database file. Sorting
data is a very
important operation in computing for many reasons. One of
those reasons is that it
makes the data more accessible to humans once it is printed
(imagine trying to use
a telephone directory in which the names do not appear in any
particular order).
Another reason is that it makes the data more quickly
searchable by the computer.
There are many large data files to use for this assignment,
but you will
only need the first one until you get on to the advanced parts.
They are all
available on blackboard, and are named people1.txt,
people2.txt, people3.txt,
people5.txt, people10.txt, people20.txt, people30.txt,
people50.txt, and
people100.txt.
Look at the file "people1.txt" with a text editor. You will see
that it
contains data about a number of people. Each line contains
exactly five items: a
person’s social security number, their first name, their last
name, their date of
birth, and state of residence. The five items are separated by
spaces, but no item
will ever contain a space. Here is a sample from the middle of
thefile:
320990814 Arthur Farmer 19560424 NV
322230050 Eros Crandon 19250819 TX
324640114 Lusitania Lissom 19440104 IN
325400784 Rose Terwilliger 19260122 WI
327640597 Jeffrey Stone 19760801 DE
327950765 Mary Emmett 19290224 CO
328610085 Heironymous Inchworm 19661102 CA
329310410 William McCormick 19550819 WV
329320248 Nicola Birchmore 19230107 IA
330270343 Pauline McTaggart 19290402 MN
331130693 Jim Trombone 19411222 NE
331960453 Abraham Larch 19750901 WY
332040687 Trixie Underwood 19200516 UT
As you may have noticed, the date of birth is provided as a
single integer, in the format
yyyymmdd; Arthur Farmer was born on the 24th of April 1956.
The 1 in the filename
people1.txt indicates that it contains exactly one thousand
lines.
2
1. Read the Data
Write a program that creates a list large enough to hold all the
data, then reads all the data
from the file into that list. Of course, it will have to be a list of
structs that you will also
need to define. Make your program close the file, then print out
the first 10 items of data from
the list, so that you can make sure everything was read
correctly.
2. Basic Search
Make your program ask the user to enter a name. It should then
search through the data in
the list (don’t read the file again), finding any entry with a
matching name. Correct matches
with either first or last name should be accepted. For every
matching entry that is found, print
out all four data items: the social security number, first and last
names, and date of birth of
each matching person.
Remember that if you use the == operator to compare strings,
the test is case-sensitive.
The user (i.e. you) will have to type the name exactly correctly,
with capital letters in the right
places.
Important: Good clean design will make this lab much easier.
Write a separate function
that searches the list, do not put all the work in main.
3. Find the Oldest
Modify your program so that after closing the file, instead of
printing the first ten items of
data, it searches through all of them to find the oldest person
represented. It should print the
social security number, first and last names, date of birth, and
state of the oldest person found.
Important: As for part two, good clean design will make this lab
much easier. Write a
separate function that searches the list to find the oldest person,
do not put all the work in
main.
4. Promote the Oldest
For some unfathomable reason, the management wants the
oldest person to occupy the
first position in the list. Modify your program so that after
finding the oldest person, it swaps
his or her data with the data already occupying the first position
in the list. Remember that the
first position in a list is numbered zero, not one.
5. Now Promote the Second Oldest.
The management has now decided not only that the oldest
person must occupy the first
position in the list, but also that the second-oldest person must
occupy the second position in
the list. So, after searching for the oldest and moving their data
to the front of the list, now
search the remainder of the list (all except the first element),
and move the oldest person you
find (which must be the second oldest of all) into the second
position of the list. Make sure
you swap data, so that whoever was originally in the second
position is not lost.
3
6. More of the Same.
The management are going to keep on adding requirements like
this, next putting the third-
oldest in the third position, then the fourth, then the fifth. There
is no knowing when they will
grow out of this petty obsession, so make things easier for
yourself. Modify your search
function so that it can be told how much of the list to search.
That is, give it two int
parameters (let’s call them a and b); its job is now to search
only the portion of the list
between position a and position b, to find the oldest person
therein. This makes it very easy to
search the remainder of the list to find the second and third
oldest.
7. The Ultimate Demand.
Now the management make their final demand. You are to
repeat the process of moving
the nth-oldest person into the nth position 1000 times. (please
remember, 1000 is the number
of data records in the whole file).
This will result in the list being completely sorted. Do it, and
check that it worked. Make
your program print the contents of the list after it has finished.
Look at the output to make sure
that everyone is printed in order of their age.
Try to implement your own selection sort function – instead of
using the Python sort.
8. Sorting the File.
Once you have sorted the contents of the list, it might be a good
idea to save the sorted
data in a file. Make your program create a new file, and write
all the contents of the list into
that file in a sensible format. Use a text editor to look at the file
and verify that it has the same
format as the original file, and all the data is properly sorted.
9. How Fast Is It?
It is important to know how long computer operations are going
to take when they have to
work on a large amount of data.
Use a function (twice) to time how long it takes the computer to
sort the list of 1000 data
items. Do not include the time it takes to read the file or the
time it takes to write the new file,
just the pure sorting time. Note the time that you observe.
Now you know how long it takes to sort a database of 1000
items. How long do you
think it would take to sort a database of 2000 names? 3000
names? 10,000 names?
Think about those questions, and work out what you believe the
answer is. Then find out
what the real answer is. The other files have exactly the same
format as people1.txt, but are
longer. PeopleN.txt contains N thousand data records. If your
program was nicely
written, it will be a few seconds’ work to change the list size
and make it read a different
file.
See how long it takes to sort these larger files, and compare the
results to your
predictions. If your predictions weren’t substantially correct,
make sure you understand
4
why. You have just demonstrated a very important phenomenon
of computing.
10. Friendships (Extra Credit Only – 200 Points)
a. Copy your code to a separate program.
b. You will work with the list of persons.
c. Implement or use a function random_in_range(int a, int b)
function to choose a
random integer number between two integers.
d. Add a friends list for your PersonType class.
e. For each person in the person list choose a number of friends
(minimum is zero and
maximum is Size/200). Assume this number is x. Now you need
to generate x
locations of the friends and add them as friends to the list of
friends of the current
person.
f. Write or use a function that will sort the list now by the
number of friends in a
descending order.
g. For each person, find other people who have common friends
with that person and
who those common friends are.
h. For each person, find all the people who have that person as a
friend.
i. Repeat part e to randomly unfriend people (unfriending is
zero to half of the number
of friends).
j. Repeat part f after you have run the unfriend part.
5
Part II (200 points)
In this assignment you will use clean structured design to solve
a
problem that is normally considered to be very difficult, and
find that it is
in fact surprisingly easy. Look before you leap: think about
how your
program is going to be organized, don’t just start typing. A
rational design
will give you a working program quite easily; an unplanned
design will not.
You need to make sure that your program will flow smoothly
and your
functions are designed with the right parameters and appropriate
data types
(you should put very little in main().
The assignment is to create a nicely formatted calendar for any
month of any year.
1. Length of a Month
Design a function that takes two parameters: year and month,
and returns an
integer indicating how many days long that month is. January
2009 was 31 days long,
February 2009 was 28 days long, February 2008 was 29 days
long, and so on.
Remember that for February, leap years must be taken into
account.
For this first part, we are only interested in the 21st century.
Between the years
2000 and 2099 the leap year rule is very simple: a year is a leap
year if it is divisible
by four.
Incorporate your function into a simple program that allows you
to test it
conveniently, and then test it conveniently. Each stage of this
lab assignment depends
on the previous stage, so you won’t do any good by going ahead
with an incorrect
function.
2. Day of the Year.
Design a function that takes three parameters: year, month, and
day, and returns
an integer indicating which day of the year that date is. For
example, the 1st of
January is day 1 of the year, the 2nd of January is day 2, the 1st
of February is day 32,
and so on.
Incorporate your function into a simple program that allows you
to test it
conveniently, and then test it thoroughly.
3. Day of the Century.
Now make a function that tells you what day of the century it is.
Forget about
foolish arguments about whether the century starts in 2000 or
2001. If you take 1st
January 2000 as day 1, everything works out nicely. So 31st
December 2000 was day
366, and 1st January 2001 was day 367, and so on. You still
only need to be
concerned with this century, 2000 to 2099.
6
4. Day of Forever.
You knew this part was coming. Now we want a function that
again takes three
parameters, representing year, month, and day, but this time, the
year could be any
positive number. This raises two issues: where to start counting
(i.e. what date shall
we choose to be day number 1?), and how to handle leap years.
Although pedantic folk will argue that there is no such thing as
the year 0,
pretending that there was makes for a very simple solution. Day
1 will be 1st January
of the year 0 regardless of whether or not that date ever existed.
It makes the counting
easy.
The true rules for leap years are slightly more complex than just
divisibility by
four. The exact rules are given on the last page if you don’t
already know them, but in
summary:
Any year that is divisible by 400 is a leap year,
any other year that is divisible by 100 is not a leap year,
any other year that is divisible by 4 is a leap year, and
any other year is not a leap year.
Here are some pre-calculated samples to help with testing:
1st January 2000 was day number 730486
4th July 1776 was day number 648857
2nd, 3rd, and 4th of October 2012 are days 735144, 735145, and
735146
27th November 2737 will be the millionth day
1st January of the year 10 A.D. was day 3654
Give some serious thought to testing. If you are getting the
wrong number for a date,
try some very close dates, and you are likely to spot a pattern in
the error that will
give you a big clue about where your program may be wrong.
5. Day of the Week.
Now make a function that takes year, month, and day as
parameters, and tells you
what day of the week that date was. In some strange and wild
countries, such as
Czechoslovakia, the week starts on a Monday. We’ll keep them
happy. Make your
function return the answer as an int, using 0 for Monday, 1 for
Tuesday, ..., and 6 for
Sunday. This is very easy if you think of the modulo %
operator and remember how
many days there are in a week. Also, make it flexible so that
you could start the
calendar on any day and you could then sell it in any strange
and wild countries.
6. A Calendar for a Month.
Use that function in a program that allows the user to enter two
integers,
representing year and month, and then prints a correctly
formatted calendar for that
day and month. Like this, which would come from an input of
2014 2:
Mo Tu We Th Fr Sa
1
Su
2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28
continued..
7
You certainly know how to print out a list of numbers starting
from 1. To make those
numbers come out looking like a calendar, you need to work out
how many spaces to
print before the “1”, and how to tell when it is time to start a
new line. You also need to
take a little care to get the alignment of one and two digit
numbers right.
7. A solid Product.
Make sure that your calendar works for any year, not just in the
21st Century,
And enable the user to print a calendar that starts on any day
not just
Monday.
8. For A Little Extra Credit.
Write a function that works out how many sundays any given
year has.
8
Only For Reference:
Rules for Leap Years
Under the Gregorian calendar system, which is what we use
now, the rules for
working out whether a particular year is a leap year or not are
If the year number is divisible by 4, it is normally a leap year,
except that if it is divisible by 100, it is not a leap year after all,
except that if it is divisible by 400, it really is a leap year again.
So, the years...
1600, 2000, 2400, 2800 are leap years
1800, 1900, 2100, 2200 are just ordinary years
1904, 1908, 2004, 2008 are leap years
1901, 1999, 2001, 2009 are ordinary years.
The Gregorian calendar was only introduced in the English-
speaking world and all
the British colonies on 14th September 1752. Before that, the
Julian calendar had been
in use since roman times. Under the Julian calendar, a leap year
is simply any year
whose number is divisible by 4. The major European countries
had switched to the
Gregorian calendar in 1582, so there was a long period of
international confusion.
Florida was a Spanish colony until 1763, British from 1763 to
1784, Spanish
again from 1784 to 1810, independent from 1810 to 1811, then
Spanish again, until it
was finally taken over by the United States in 1821. There isn’t
much to be gained by
trying to take all of those changes into account. Throughout the
United States, the
date for the change is taken to have been 14th September 1752
even in places where it
wasn’t really.
1752 was a very confusing and tempestuous year. All of a
sudden 11 leap years
that had contributed an extra 29th of February didn’t count as
leap years any more,
and those 11 days had to be given back. The chosen solution
was that the 3rd to 13th
days of September just didn’t happen that year. This is the
correct calendar for the
period:
August 1752 September 1752 October 1752
Su Mo Tu We Th Fr Sa
1
Su Mo Tu
1
We
2
Th
14
Fr
15
Sa
16
Su
1
Mo
2
Tu
3
We
4
Th
5
Fr
6
Sa
7
2 3 4 5 6 7 8 17 18 19 20 21 22
23 8 9 10 11 12 13 14
9 10 11 12 13 14 15 24 25 26 27 28 29
30 15 16 17 18 19 20 21
16 17 18 19 20 21 22 22 23 24 25 26 27
28
23 24 25 26 27 28 29 29 30 31
30 31
You do not need to make your calendar program take account of
the Julian period in
any way. Just pretend that the current system has always been in
place.
9
Submission
• You MUST submit the following items to BB:
üOne Word file for the assignment – the whole thing is ONE
word file
with the code for each of the 2 problems above and the next
part.
üAll Output files
üScreenshots of all your outputs in the same word document (If
you don’t
include it, you get a zero for the assignment)
• One upload of all files together is allowed
• No email submissions will be accepted under any
circumstances
• Emails saying the wrong files were submitted will be
completely
ignored. You should know how to do this by now!
• Please be careful – your code will be checked against code of
other students
and internet code (I have the tools) – you must do this on your
own (don’t
risk it)
• If I suspect that you submitted code that is not yours, you will
receive a zero
for the assignment, and will be invited to my office to make
changes to the
code before I would give a score for the assignment.
RULES FOR ANSWERING SPECIAL DISCUSSION BOARD
QUESTIONS:
1) Remember, you need to demonstrate an understanding of
events--not only in terms of what happened but also why it
happened and what effect it had on society. Remember to
answer each part of your question as well.
2) Stay on target—answer the questions as fully as possible and
don’t wander off the subject—doing so will hurt your grade.
3) Be aware that you are required to use resources other than
your textbook in composing your answers to Special Discussion
Board Questions. You are also required to cite those sources at
the end of your posting. This means you may need to take a trip
to your local library or conduct an online search or two before
you have the information necessary for you to compose your
posting. DO NOT use any of the following as sources: your
textbook, films or television programs (so no You Tube), blogs,
Twitter posts, or Facebook pages. DO NOT use endnotes,
footnotes, or any other form of source citation within the body
of your post. You will lose points for each instance if you do.
4) Express yourself clearly. Use good grammar and spelling.
Write in complete sentences. Do not use any of those
abbreviations so commonly used on blogs and text messages. I
suggest you compose your contribution on a word processing
program with a spell-checker. Then cut and paste—or type it in.
This may help you get out everything you want to say before
you hit “submit.” Be sure to use at least 12 point type for your
response so it can be read. And, no, you cannot edit your
contributions after they are posted.
5) Your contributions should have real substance to them.
Contributions such as “Yeah, what she said.” or “I do so totally
agree with what everyone has said” will receive zero (0) points.
Most questions can be answers in 1,000 - 1,500 words--
sometimes more, sometimes less. The best rule of thumb is to
make sure you answer each part of the question in detail.
6) Be polite—no name calling, no long-winded attempts to
dominate the discussion, no profanity, no threats. If you
disagree with someone, you may say so and then present YOUR
argument—spending your time tearing down THEIR argument
will hurt your grade and could get you thrown off the
Discussion Board.
7. Be sure the paper is Plagiarism Free.
Write an essay on the Black Death in which you answer all
of the following questions:
The Black Death (a combination of diseases including the
Bubonic Plague) hits Europe in 1348 and kills off
approximately 75% of the human population. So, let's test your
Black Death IQ. DO NOT write a list of answers to the
questions--I am looking for your ability to tell me what it all
means, too. Also, be as specific and detailed with your
information as possible.
1) The best guess is that the Black Death was spread by the bite
of infected fleas that live on the Black Rat. Why were there so
many rats? Why were there so few cats to kill the rats? And
what other roles did humans play in rat overpopulation?
2) In any given town where the Black Death hit, it counted the
members of which two occupations among its first victims?
Why is it that those individuals would be especially vulnerable?
3) In searching for a cause for their suffering, who did
Europeans blame for the Black Death and how did they seek
revenge? Name at least two of these groups and give at least
two detailed examples of this persecution.
4) What changes in social customs and attitudes came about in
Europe as a result of the Black Death?
5) What changes in literature and art came about in Europe as a
result of the Black Death?
6) How did the Black Death affect the Muslim world? In
particular, who was blamed for the disease; and how did the
treatment of Muslim victims differ from the treatment of
victims in Europe? Most important here, how does the course
of scientific inquiry in the Middle East diverge from that in
Europe in the wake of the Black Death?
7) What did an "innocent" nursery rhyme like Ring Around the
Rosie have to do with the Black Death? (in your research you
may run across a school of thought that says it didn't...ignore
that school of thought)
Be sure to include your list of sources with your post.

More Related Content

Similar to 1 Summer2017Assignment4IndividualAssignment-Due.docx

Hello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdfHello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdf
actioncbe1
 
EEC 144 Laboratory 1 Identifying a Workstation’s.docx
EEC 144 Laboratory 1 Identifying a Workstation’s.docxEEC 144 Laboratory 1 Identifying a Workstation’s.docx
EEC 144 Laboratory 1 Identifying a Workstation’s.docx
toltonkendal
 
You are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdfYou are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdf
FOREVERPRODUCTCHD
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx
honey690131
 
Rhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docx
Rhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docxRhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docx
Rhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docx
joellemurphey
 
Assignment 3 Presenting With PowerPointJane R. Doe .docx
Assignment 3 Presenting With PowerPointJane R. Doe           .docxAssignment 3 Presenting With PowerPointJane R. Doe           .docx
Assignment 3 Presenting With PowerPointJane R. Doe .docx
rock73
 
These are just examples from previous classes not for this week cl.docx
These are just examples from previous classes not for this week cl.docxThese are just examples from previous classes not for this week cl.docx
These are just examples from previous classes not for this week cl.docx
christalgrieg
 
DeepSearch_Project_Report
DeepSearch_Project_ReportDeepSearch_Project_Report
DeepSearch_Project_Report
Urjit Patel
 
SEE-20-STRUCTURE-OF-Technical writing.pptx
SEE-20-STRUCTURE-OF-Technical writing.pptxSEE-20-STRUCTURE-OF-Technical writing.pptx
SEE-20-STRUCTURE-OF-Technical writing.pptx
MelayAlmorado1
 
FInal Project Intelligent Social Media Analytics
FInal Project Intelligent Social Media AnalyticsFInal Project Intelligent Social Media Analytics
FInal Project Intelligent Social Media Analytics
Ashwin Dinoriya
 
Using microsoftaccess1 gettingstarted
Using microsoftaccess1 gettingstartedUsing microsoftaccess1 gettingstarted
Using microsoftaccess1 gettingstarted
jcjo05
 

Similar to 1 Summer2017Assignment4IndividualAssignment-Due.docx (20)

Hello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdfHello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdf
 
Cleaning and sorting data
Cleaning and sorting dataCleaning and sorting data
Cleaning and sorting data
 
toolkit13_sec9.pdf
toolkit13_sec9.pdftoolkit13_sec9.pdf
toolkit13_sec9.pdf
 
EEC 144 Laboratory 1 Identifying a Workstation’s.docx
EEC 144 Laboratory 1 Identifying a Workstation’s.docxEEC 144 Laboratory 1 Identifying a Workstation’s.docx
EEC 144 Laboratory 1 Identifying a Workstation’s.docx
 
You are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdfYou are asked with writing a program in C that manages contact infor.pdf
You are asked with writing a program in C that manages contact infor.pdf
 
Beautiful Research Data (Structured Data and Open Refine)
Beautiful Research Data (Structured Data and Open Refine)Beautiful Research Data (Structured Data and Open Refine)
Beautiful Research Data (Structured Data and Open Refine)
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx
 
Rhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docx
Rhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docxRhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docx
Rhetorical Strategies and Fallacies WorksheetPHL320 Version 3.docx
 
Introduction to Data Science With R Notes
Introduction to Data Science With R NotesIntroduction to Data Science With R Notes
Introduction to Data Science With R Notes
 
Assignment 3 Presenting With PowerPointJane R. Doe .docx
Assignment 3 Presenting With PowerPointJane R. Doe           .docxAssignment 3 Presenting With PowerPointJane R. Doe           .docx
Assignment 3 Presenting With PowerPointJane R. Doe .docx
 
These are just examples from previous classes not for this week cl.docx
These are just examples from previous classes not for this week cl.docxThese are just examples from previous classes not for this week cl.docx
These are just examples from previous classes not for this week cl.docx
 
DeepSearch_Project_Report
DeepSearch_Project_ReportDeepSearch_Project_Report
DeepSearch_Project_Report
 
SEE-20-STRUCTURE-OF-Technical writing.pptx
SEE-20-STRUCTURE-OF-Technical writing.pptxSEE-20-STRUCTURE-OF-Technical writing.pptx
SEE-20-STRUCTURE-OF-Technical writing.pptx
 
FInal Project Intelligent Social Media Analytics
FInal Project Intelligent Social Media AnalyticsFInal Project Intelligent Social Media Analytics
FInal Project Intelligent Social Media Analytics
 
Using microsoftaccess1 gettingstarted
Using microsoftaccess1 gettingstartedUsing microsoftaccess1 gettingstarted
Using microsoftaccess1 gettingstarted
 
Unit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxUnit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptx
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
lessonplan.docx
lessonplan.docxlessonplan.docx
lessonplan.docx
 
Search++ Manual
Search++ ManualSearch++ Manual
Search++ Manual
 
Numerical data.
Numerical data.Numerical data.
Numerical data.
 

More from honey725342

NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docxNRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
honey725342
 
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docxNow the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
honey725342
 
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docxNurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
honey725342
 
Now that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docxNow that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docx
honey725342
 
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
NR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docxNR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docx
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
honey725342
 
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docxNURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
honey725342
 
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docxNur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
honey725342
 
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docxNU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
honey725342
 
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
NR631 Concluding Graduate Experience - Scope  Project Managemen.docxNR631 Concluding Graduate Experience - Scope  Project Managemen.docx
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
honey725342
 

More from honey725342 (20)

NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docxNRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
NRS-493 Individual Success PlanREQUIRED PRACTICE HOURS 100 Direct.docx
 
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docxNow the Earth has had wide variations in atmospheric CO2-level throu.docx
Now the Earth has had wide variations in atmospheric CO2-level throu.docx
 
NR224 Fundamentals SkillsTopic Safety Goals BOOK P.docx
NR224 Fundamentals SkillsTopic Safety Goals BOOK P.docxNR224 Fundamentals SkillsTopic Safety Goals BOOK P.docx
NR224 Fundamentals SkillsTopic Safety Goals BOOK P.docx
 
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docxNurse Education Today 87 (2020) 104348Contents lists avail.docx
Nurse Education Today 87 (2020) 104348Contents lists avail.docx
 
Now that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docxNow that you’ve seen all of the elements contributing to the Devil’s.docx
Now that you’ve seen all of the elements contributing to the Devil’s.docx
 
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
NR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docxNR360   We   Can   But   Dare   We.docx   Revised   5 ‐ 9 .docx
NR360 We Can But Dare We.docx Revised 5 ‐ 9 .docx
 
Nurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docx
Nurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docxNurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docx
Nurse Practitioner Diagnosis- Chest Pain.SOAPS-Subjective.docx
 
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docxNURS 6002 Foundations of Graduate StudyAcademic and P.docx
NURS 6002 Foundations of Graduate StudyAcademic and P.docx
 
Nurse workforce shortage are predicted to get worse as baby boomers .docx
Nurse workforce shortage are predicted to get worse as baby boomers .docxNurse workforce shortage are predicted to get worse as baby boomers .docx
Nurse workforce shortage are predicted to get worse as baby boomers .docx
 
Now, for the exam itself. Below are 4 questions. You need to answer .docx
Now, for the exam itself. Below are 4 questions. You need to answer .docxNow, for the exam itself. Below are 4 questions. You need to answer .docx
Now, for the exam itself. Below are 4 questions. You need to answer .docx
 
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docxNur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
Nur-501-AP4- Philosophical and Theoretical Evidence-Based research.docx
 
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docxNU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
NU32CH19-Foltz ARI 9 July 2012 1945Population-Level Inter.docx
 
Nurse Working in the CommunityDescribe the community nurses.docx
Nurse Working in the CommunityDescribe the community nurses.docxNurse Working in the CommunityDescribe the community nurses.docx
Nurse Working in the CommunityDescribe the community nurses.docx
 
nursing diagnosis1. Decreased Cardiac Output  related to Alter.docx
nursing diagnosis1. Decreased Cardiac Output  related to Alter.docxnursing diagnosis1. Decreased Cardiac Output  related to Alter.docx
nursing diagnosis1. Decreased Cardiac Output  related to Alter.docx
 
Nursing Documentation Is it valuable Discuss the value of nursin.docx
Nursing Documentation Is it valuable Discuss the value of nursin.docxNursing Documentation Is it valuable Discuss the value of nursin.docx
Nursing Documentation Is it valuable Discuss the value of nursin.docx
 
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
NR631 Concluding Graduate Experience - Scope  Project Managemen.docxNR631 Concluding Graduate Experience - Scope  Project Managemen.docx
NR631 Concluding Graduate Experience - Scope Project Managemen.docx
 
Number 11. Describe at least five populations who are vulner.docx
Number 11. Describe at least five populations who are vulner.docxNumber 11. Describe at least five populations who are vulner.docx
Number 11. Describe at least five populations who are vulner.docx
 
ntertainment, the media, and sometimes public leaders can perpetuate.docx
ntertainment, the media, and sometimes public leaders can perpetuate.docxntertainment, the media, and sometimes public leaders can perpetuate.docx
ntertainment, the media, and sometimes public leaders can perpetuate.docx
 
Now that you have  completed Lesson 23 & 24 and have thought a.docx
Now that you have  completed Lesson 23 & 24 and have thought a.docxNow that you have  completed Lesson 23 & 24 and have thought a.docx
Now that you have  completed Lesson 23 & 24 and have thought a.docx
 
nothing wrong with the paper, my professor just wants it to be in an.docx
nothing wrong with the paper, my professor just wants it to be in an.docxnothing wrong with the paper, my professor just wants it to be in an.docx
nothing wrong with the paper, my professor just wants it to be in an.docx
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
Krashi Coaching
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 

1 Summer2017Assignment4IndividualAssignment-Due.docx

  • 1. 1 Summer 2017 Assignment 4 IndividualAssignment - Due June27, 2017 (400 Points) Part I (200 points) In this assignment, you will be performing some important data- processing operations, specifically sorting a large database file. Sorting data is a very important operation in computing for many reasons. One of those reasons is that it makes the data more accessible to humans once it is printed (imagine trying to use a telephone directory in which the names do not appear in any particular order). Another reason is that it makes the data more quickly searchable by the computer. There are many large data files to use for this assignment, but you will only need the first one until you get on to the advanced parts. They are all available on blackboard, and are named people1.txt, people2.txt, people3.txt, people5.txt, people10.txt, people20.txt, people30.txt, people50.txt, and people100.txt.
  • 2. Look at the file "people1.txt" with a text editor. You will see that it contains data about a number of people. Each line contains exactly five items: a person’s social security number, their first name, their last name, their date of birth, and state of residence. The five items are separated by spaces, but no item will ever contain a space. Here is a sample from the middle of thefile: 320990814 Arthur Farmer 19560424 NV 322230050 Eros Crandon 19250819 TX 324640114 Lusitania Lissom 19440104 IN 325400784 Rose Terwilliger 19260122 WI 327640597 Jeffrey Stone 19760801 DE 327950765 Mary Emmett 19290224 CO 328610085 Heironymous Inchworm 19661102 CA 329310410 William McCormick 19550819 WV 329320248 Nicola Birchmore 19230107 IA 330270343 Pauline McTaggart 19290402 MN 331130693 Jim Trombone 19411222 NE 331960453 Abraham Larch 19750901 WY 332040687 Trixie Underwood 19200516 UT As you may have noticed, the date of birth is provided as a single integer, in the format yyyymmdd; Arthur Farmer was born on the 24th of April 1956. The 1 in the filename people1.txt indicates that it contains exactly one thousand lines.
  • 3. 2 1. Read the Data Write a program that creates a list large enough to hold all the data, then reads all the data from the file into that list. Of course, it will have to be a list of structs that you will also need to define. Make your program close the file, then print out the first 10 items of data from the list, so that you can make sure everything was read correctly. 2. Basic Search Make your program ask the user to enter a name. It should then search through the data in the list (don’t read the file again), finding any entry with a matching name. Correct matches with either first or last name should be accepted. For every matching entry that is found, print out all four data items: the social security number, first and last names, and date of birth of each matching person. Remember that if you use the == operator to compare strings, the test is case-sensitive. The user (i.e. you) will have to type the name exactly correctly, with capital letters in the right places. Important: Good clean design will make this lab much easier. Write a separate function that searches the list, do not put all the work in main.
  • 4. 3. Find the Oldest Modify your program so that after closing the file, instead of printing the first ten items of data, it searches through all of them to find the oldest person represented. It should print the social security number, first and last names, date of birth, and state of the oldest person found. Important: As for part two, good clean design will make this lab much easier. Write a separate function that searches the list to find the oldest person, do not put all the work in main. 4. Promote the Oldest For some unfathomable reason, the management wants the oldest person to occupy the first position in the list. Modify your program so that after finding the oldest person, it swaps his or her data with the data already occupying the first position in the list. Remember that the first position in a list is numbered zero, not one. 5. Now Promote the Second Oldest. The management has now decided not only that the oldest person must occupy the first position in the list, but also that the second-oldest person must occupy the second position in the list. So, after searching for the oldest and moving their data to the front of the list, now search the remainder of the list (all except the first element),
  • 5. and move the oldest person you find (which must be the second oldest of all) into the second position of the list. Make sure you swap data, so that whoever was originally in the second position is not lost. 3 6. More of the Same. The management are going to keep on adding requirements like this, next putting the third- oldest in the third position, then the fourth, then the fifth. There is no knowing when they will grow out of this petty obsession, so make things easier for yourself. Modify your search function so that it can be told how much of the list to search. That is, give it two int parameters (let’s call them a and b); its job is now to search only the portion of the list between position a and position b, to find the oldest person therein. This makes it very easy to search the remainder of the list to find the second and third oldest. 7. The Ultimate Demand. Now the management make their final demand. You are to repeat the process of moving the nth-oldest person into the nth position 1000 times. (please remember, 1000 is the number of data records in the whole file).
  • 6. This will result in the list being completely sorted. Do it, and check that it worked. Make your program print the contents of the list after it has finished. Look at the output to make sure that everyone is printed in order of their age. Try to implement your own selection sort function – instead of using the Python sort. 8. Sorting the File. Once you have sorted the contents of the list, it might be a good idea to save the sorted data in a file. Make your program create a new file, and write all the contents of the list into that file in a sensible format. Use a text editor to look at the file and verify that it has the same format as the original file, and all the data is properly sorted. 9. How Fast Is It? It is important to know how long computer operations are going to take when they have to work on a large amount of data. Use a function (twice) to time how long it takes the computer to sort the list of 1000 data items. Do not include the time it takes to read the file or the time it takes to write the new file, just the pure sorting time. Note the time that you observe.
  • 7. Now you know how long it takes to sort a database of 1000 items. How long do you think it would take to sort a database of 2000 names? 3000 names? 10,000 names? Think about those questions, and work out what you believe the answer is. Then find out what the real answer is. The other files have exactly the same format as people1.txt, but are longer. PeopleN.txt contains N thousand data records. If your program was nicely written, it will be a few seconds’ work to change the list size and make it read a different file. See how long it takes to sort these larger files, and compare the results to your predictions. If your predictions weren’t substantially correct, make sure you understand 4 why. You have just demonstrated a very important phenomenon of computing. 10. Friendships (Extra Credit Only – 200 Points)
  • 8. a. Copy your code to a separate program. b. You will work with the list of persons. c. Implement or use a function random_in_range(int a, int b) function to choose a random integer number between two integers. d. Add a friends list for your PersonType class. e. For each person in the person list choose a number of friends (minimum is zero and maximum is Size/200). Assume this number is x. Now you need to generate x locations of the friends and add them as friends to the list of friends of the current person. f. Write or use a function that will sort the list now by the number of friends in a descending order. g. For each person, find other people who have common friends with that person and who those common friends are. h. For each person, find all the people who have that person as a friend. i. Repeat part e to randomly unfriend people (unfriending is zero to half of the number of friends). j. Repeat part f after you have run the unfriend part.
  • 9. 5 Part II (200 points) In this assignment you will use clean structured design to solve a problem that is normally considered to be very difficult, and find that it is in fact surprisingly easy. Look before you leap: think about how your program is going to be organized, don’t just start typing. A rational design will give you a working program quite easily; an unplanned design will not. You need to make sure that your program will flow smoothly and your functions are designed with the right parameters and appropriate data types (you should put very little in main(). The assignment is to create a nicely formatted calendar for any month of any year. 1. Length of a Month Design a function that takes two parameters: year and month, and returns an integer indicating how many days long that month is. January 2009 was 31 days long, February 2009 was 28 days long, February 2008 was 29 days long, and so on.
  • 10. Remember that for February, leap years must be taken into account. For this first part, we are only interested in the 21st century. Between the years 2000 and 2099 the leap year rule is very simple: a year is a leap year if it is divisible by four. Incorporate your function into a simple program that allows you to test it conveniently, and then test it conveniently. Each stage of this lab assignment depends on the previous stage, so you won’t do any good by going ahead with an incorrect function. 2. Day of the Year. Design a function that takes three parameters: year, month, and day, and returns an integer indicating which day of the year that date is. For example, the 1st of January is day 1 of the year, the 2nd of January is day 2, the 1st of February is day 32, and so on. Incorporate your function into a simple program that allows you to test it conveniently, and then test it thoroughly. 3. Day of the Century. Now make a function that tells you what day of the century it is. Forget about
  • 11. foolish arguments about whether the century starts in 2000 or 2001. If you take 1st January 2000 as day 1, everything works out nicely. So 31st December 2000 was day 366, and 1st January 2001 was day 367, and so on. You still only need to be concerned with this century, 2000 to 2099. 6 4. Day of Forever. You knew this part was coming. Now we want a function that again takes three parameters, representing year, month, and day, but this time, the year could be any positive number. This raises two issues: where to start counting (i.e. what date shall we choose to be day number 1?), and how to handle leap years. Although pedantic folk will argue that there is no such thing as the year 0, pretending that there was makes for a very simple solution. Day 1 will be 1st January of the year 0 regardless of whether or not that date ever existed. It makes the counting easy. The true rules for leap years are slightly more complex than just divisibility by four. The exact rules are given on the last page if you don’t already know them, but in summary:
  • 12. Any year that is divisible by 400 is a leap year, any other year that is divisible by 100 is not a leap year, any other year that is divisible by 4 is a leap year, and any other year is not a leap year. Here are some pre-calculated samples to help with testing: 1st January 2000 was day number 730486 4th July 1776 was day number 648857 2nd, 3rd, and 4th of October 2012 are days 735144, 735145, and 735146 27th November 2737 will be the millionth day 1st January of the year 10 A.D. was day 3654 Give some serious thought to testing. If you are getting the wrong number for a date, try some very close dates, and you are likely to spot a pattern in the error that will give you a big clue about where your program may be wrong. 5. Day of the Week. Now make a function that takes year, month, and day as parameters, and tells you what day of the week that date was. In some strange and wild countries, such as Czechoslovakia, the week starts on a Monday. We’ll keep them happy. Make your function return the answer as an int, using 0 for Monday, 1 for Tuesday, ..., and 6 for Sunday. This is very easy if you think of the modulo % operator and remember how many days there are in a week. Also, make it flexible so that you could start the calendar on any day and you could then sell it in any strange and wild countries.
  • 13. 6. A Calendar for a Month. Use that function in a program that allows the user to enter two integers, representing year and month, and then prints a correctly formatted calendar for that day and month. Like this, which would come from an input of 2014 2: Mo Tu We Th Fr Sa 1 Su 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 continued.. 7 You certainly know how to print out a list of numbers starting from 1. To make those numbers come out looking like a calendar, you need to work out how many spaces to print before the “1”, and how to tell when it is time to start a new line. You also need to take a little care to get the alignment of one and two digit numbers right.
  • 14. 7. A solid Product. Make sure that your calendar works for any year, not just in the 21st Century, And enable the user to print a calendar that starts on any day not just Monday. 8. For A Little Extra Credit. Write a function that works out how many sundays any given year has. 8 Only For Reference: Rules for Leap Years Under the Gregorian calendar system, which is what we use now, the rules for working out whether a particular year is a leap year or not are If the year number is divisible by 4, it is normally a leap year, except that if it is divisible by 100, it is not a leap year after all, except that if it is divisible by 400, it really is a leap year again. So, the years... 1600, 2000, 2400, 2800 are leap years 1800, 1900, 2100, 2200 are just ordinary years
  • 15. 1904, 1908, 2004, 2008 are leap years 1901, 1999, 2001, 2009 are ordinary years. The Gregorian calendar was only introduced in the English- speaking world and all the British colonies on 14th September 1752. Before that, the Julian calendar had been in use since roman times. Under the Julian calendar, a leap year is simply any year whose number is divisible by 4. The major European countries had switched to the Gregorian calendar in 1582, so there was a long period of international confusion. Florida was a Spanish colony until 1763, British from 1763 to 1784, Spanish again from 1784 to 1810, independent from 1810 to 1811, then Spanish again, until it was finally taken over by the United States in 1821. There isn’t much to be gained by trying to take all of those changes into account. Throughout the United States, the date for the change is taken to have been 14th September 1752 even in places where it wasn’t really. 1752 was a very confusing and tempestuous year. All of a sudden 11 leap years that had contributed an extra 29th of February didn’t count as leap years any more, and those 11 days had to be given back. The chosen solution was that the 3rd to 13th days of September just didn’t happen that year. This is the correct calendar for the period:
  • 16. August 1752 September 1752 October 1752 Su Mo Tu We Th Fr Sa 1 Su Mo Tu 1 We 2 Th 14 Fr 15 Sa 16 Su 1 Mo 2 Tu 3 We 4 Th 5 Fr 6 Sa
  • 17. 7 2 3 4 5 6 7 8 17 18 19 20 21 22 23 8 9 10 11 12 13 14 9 10 11 12 13 14 15 24 25 26 27 28 29 30 15 16 17 18 19 20 21 16 17 18 19 20 21 22 22 23 24 25 26 27 28 23 24 25 26 27 28 29 29 30 31 30 31 You do not need to make your calendar program take account of the Julian period in any way. Just pretend that the current system has always been in place. 9 Submission • You MUST submit the following items to BB: üOne Word file for the assignment – the whole thing is ONE word file with the code for each of the 2 problems above and the next part. üAll Output files üScreenshots of all your outputs in the same word document (If you don’t include it, you get a zero for the assignment) • One upload of all files together is allowed • No email submissions will be accepted under any circumstances
  • 18. • Emails saying the wrong files were submitted will be completely ignored. You should know how to do this by now! • Please be careful – your code will be checked against code of other students and internet code (I have the tools) – you must do this on your own (don’t risk it) • If I suspect that you submitted code that is not yours, you will receive a zero for the assignment, and will be invited to my office to make changes to the code before I would give a score for the assignment. RULES FOR ANSWERING SPECIAL DISCUSSION BOARD QUESTIONS: 1) Remember, you need to demonstrate an understanding of events--not only in terms of what happened but also why it happened and what effect it had on society. Remember to answer each part of your question as well. 2) Stay on target—answer the questions as fully as possible and don’t wander off the subject—doing so will hurt your grade. 3) Be aware that you are required to use resources other than your textbook in composing your answers to Special Discussion Board Questions. You are also required to cite those sources at the end of your posting. This means you may need to take a trip to your local library or conduct an online search or two before you have the information necessary for you to compose your posting. DO NOT use any of the following as sources: your textbook, films or television programs (so no You Tube), blogs,
  • 19. Twitter posts, or Facebook pages. DO NOT use endnotes, footnotes, or any other form of source citation within the body of your post. You will lose points for each instance if you do. 4) Express yourself clearly. Use good grammar and spelling. Write in complete sentences. Do not use any of those abbreviations so commonly used on blogs and text messages. I suggest you compose your contribution on a word processing program with a spell-checker. Then cut and paste—or type it in. This may help you get out everything you want to say before you hit “submit.” Be sure to use at least 12 point type for your response so it can be read. And, no, you cannot edit your contributions after they are posted. 5) Your contributions should have real substance to them. Contributions such as “Yeah, what she said.” or “I do so totally agree with what everyone has said” will receive zero (0) points. Most questions can be answers in 1,000 - 1,500 words-- sometimes more, sometimes less. The best rule of thumb is to make sure you answer each part of the question in detail. 6) Be polite—no name calling, no long-winded attempts to dominate the discussion, no profanity, no threats. If you disagree with someone, you may say so and then present YOUR argument—spending your time tearing down THEIR argument will hurt your grade and could get you thrown off the Discussion Board. 7. Be sure the paper is Plagiarism Free. Write an essay on the Black Death in which you answer all of the following questions: The Black Death (a combination of diseases including the Bubonic Plague) hits Europe in 1348 and kills off approximately 75% of the human population. So, let's test your Black Death IQ. DO NOT write a list of answers to the questions--I am looking for your ability to tell me what it all means, too. Also, be as specific and detailed with your information as possible. 1) The best guess is that the Black Death was spread by the bite
  • 20. of infected fleas that live on the Black Rat. Why were there so many rats? Why were there so few cats to kill the rats? And what other roles did humans play in rat overpopulation? 2) In any given town where the Black Death hit, it counted the members of which two occupations among its first victims? Why is it that those individuals would be especially vulnerable? 3) In searching for a cause for their suffering, who did Europeans blame for the Black Death and how did they seek revenge? Name at least two of these groups and give at least two detailed examples of this persecution. 4) What changes in social customs and attitudes came about in Europe as a result of the Black Death? 5) What changes in literature and art came about in Europe as a result of the Black Death? 6) How did the Black Death affect the Muslim world? In particular, who was blamed for the disease; and how did the treatment of Muslim victims differ from the treatment of victims in Europe? Most important here, how does the course of scientific inquiry in the Middle East diverge from that in Europe in the wake of the Black Death? 7) What did an "innocent" nursery rhyme like Ring Around the Rosie have to do with the Black Death? (in your research you may run across a school of thought that says it didn't...ignore that school of thought) Be sure to include your list of sources with your post.