ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 26 Apr 2017 My Price 8.00

CPSC 217 Exercise 4

can you create a program for this? give me some help on python 

 

 

CPSC 217 Exercise 4: The Exercise Due on the 17th Day of the 3rd Month
Due: Friday March 17, 2017
This exercise may be completed individually or as part of a group. If the exercise is completed as a group
then all members of the group are expected to make a meaningful contribution to the solution. Task:
In English, ordinal numbers like first, second, and third are sometimes written as a numeral followed by
two letters such as 1st, 2nd and 3rd. While this is easy enough for a person to do, it actually causes a
little bit of trouble in a computer program because of the different suffixes used for different numbers.
The suffix can be determined using the following rules:
•
•
•
•
• Any number that ends in 11, 12 or 13 uses a th suffix
All remaining numbers that end in 1 use an st suffix
All remaining numbers that end in 2 use an nd suffix
All remaining numbers that end in 3 use an rd suffix
All remaining numbers use a th suffix Write a function that takes an integer as its only parameter and returns the appropriate suffix for the
ordinal abbreviation of that integer as its only result. For example, if your function is passed the integer
1 then it should return the string "st". If it is passed the integer 12 then it should return the string "th".
If it is passed 2003 then it should return the string "rd". Your function must not print anything on the
screen.
Write a main program that reads three integers from the user that represent a day, a month, and a year.
Display the message "On the A day of the B month of the C year, something amazing happened!" with A,
B and C replaced with the ordinal abbreviation for the day, month and year entered by the user
(including both the numeric part and the appropriate suffix). For example, if the user enters 29, 2 and
1904 (each on its own line) then your program should display "On the 29th day of the 2nd month of the
1904th year, something amazing happened!"
Your program does not need to do any error checking. You can assume that the inputs will always be
integers greater than 0.
Hints:
• • You can use the remainder operator to extract the last digit of an integer by computing the
remainder when the integer is divided by 10, or the last two digits of an integer by computing
the remainder when the integer is divided by 100.
You can convert an integer into a string by calling the str function. Then you can
concatenate the result of that function call to another string. This will let you eliminate
undesirable spaces in your output. Sample Run #1:
Enter a day: 17
Enter a month: 3
Enter a year: 2017
On the 17th day of the 3rd month of the 2017th year, something amazing
happened! Sample Run #2:
Enter a day: 1
Enter a month: 2
Enter a year: 3
On the 1st day of the 2nd month of the 3rd year, something amazing
happened! Grading:
Your program will be graded by testing it with two different sets of input, which may be different from
the examples shown above. Your program must use a function to convert from an integer to its ordinal
number. A program that does not use a function that takes one integer parameter and return a string
result will receive a grade of F even if all of the output is correct. Your function must not print out the
result. The spacing in your program should match the samples shown above. In particular, the two
character suffix should appear right next to the integer value without any spaces in between them. Submission Instructions:
Submit your solution as a Python source code file electronically to the Exercise 4 drop box in D2L. You
do not need to submit a paper copy of your solution. If you choose to complete this exercise as part of
group then each member of the group must submit a copy of the exercise using D2L.

Attachments:

Answers

(11)
Status NEW Posted 26 Apr 2017 08:04 AM My Price 8.00

-----------

Attachments

file 1493196952-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)