Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java please. Thank you COMP 1900 - Spring 2019 Lab 6 Homework Total Points: 15 As with ll other lale, this slontkel done individually.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

In java please. Thank you

COMP 1900 - Spring 2019 Lab 6 Homework Total Points: 15 As with ll other lale, this slontkel done individually. Coutact your instruetor and/or visit the Computer Sciner tarn: n Cntr (https://www.neaphis.edu/ce/current-students/csle.php) f yon nel help. Ye ay als work with other studeuts un geucral solution idevs, but the code you submit must be your owu. Due: By the beginning of your next lab sessio Grades Your lib TA will grule your work. Qurstions about grading shonld be directed to him/her. TA contaet info cau be founci on the course syllabus. Coding Stvle the consistit indentation iti your cole; neln Ir is reisunabl-amount of comments tironglhont your code and ne standard Java conventions for ClassNames, variableNames methodNames, and CONSTANT NAMES. Your TA may deduet points for poor coding styk. Within the 1900 folder on your desktop, creute a new tolder named Lab6HWLastnaneFirstnane (4 pts) Problem 1 An ordinal number ca be thought of as tle "udjective form" of a number. Excamples of ordinal numbers are 1st, 78th, and 782ud. In English, an ordinal number can usually be producrd by adding "th" to the end of the number, but there are exceptias for numbers ending in 1 (1st, 101st), 2 (2nd, 892nd) or 3 (3rd, 4573rd). There's al an excvption to that exeeption for numbers that end in 11, 12, or 13- these just us the standard th (111th, 8013th). (1s't natural lauguagy woncler fiul??) Within your Lab6HW folter, create a uew elass named OrdinalNumbers. java. Within that elass, write a method named toordinal that takes one int pareter and returns the ordinal version of that parameter as a string. If the parameter is negative, toordinal shonld return the string "invalid". toordinal sliould rk corretlv for nny non-negative int value. that the double quotes in the return values simply indicate that thew themselves should pot be included us characters within the strings. Here are some example arguments for the toordinal method and their expected return values. Note are strings- the double quotes 70 'invalid" "Oth" *612th" 9922nd" 9922 2147483643 "2147483643rd" (3 pts) Problem 2 Within the snme Ordinal Numbers. java class as the previous problem. write a main method that allows repeatedlly call toordinal aund print the ordinal aumbers in that runge, inclusive. Here's an exiuple of what your completed program might look like when you run it. Uaderlined parts peiy a rang of integers by entering a lower aud upper limit. The program shonld then indicate what yon type in as the program is running. Enter lover limit: 16 Enter upper limit: 28 16th 17th 18th 19th 20th 21st 22nd 23rd 24th 25th 26th 27th 28th (5 pts) Problem 3 Suppose you have a rollection of 1 sloths: Alarrity. Blur, Celerity, and Dangimfast. You want to take theu cruisiug with yot, but unfortuuately your car eaul comfortably seat only 3 sloths-these are large animals that need their personal space! There are 4 ways you cau cheuse the sloths that go with yon: Alacrity, Blhu, Celerity Macrity, Blur, Dangimfast .Alacrity, Celerity. Dangimfast . Blur, Celerity. Dangimfast Note that this dors not take into accout the ordler in which you pick the sinths - all you care about is which sloths are coning aloug. Chouming Macrity, then Blur, tieu Celerity is the same as chousing Celerity, thei Blur, then Alacrity. In math. the set of 3 sloths thust you choose is known as a combination. conbinutiones of k items cluvxen fruan a set of n items i usuly wrten as () (propounced "n chooe The number of posilble ) and is computalble using this for mula: na! Yon can eusily verify that euution (1) works for the sloth seeuario, where n - 4 and k 3: (3 pts) Problem 4 One intersting application of coubinations is lattery games like Power ball. As of 2019, a Powerball plyvr chooses 5 distint (ie, non-repenting) nnumhers fromi 1-69. Note that this bs exaetly the n clsose k problemi, with n- G9 and k 5. In addition. the player chouses a Powerball number from 1-26. The total number of ways this can be dotr s (n") x 2G-: 2,2.201 winning the Jackpot is 1/292.201.338 or abort 0.00000034%. In fact, you could sell your million-dollar g a single ticket's chanee of a on,s th . pr cots to bur 500 ri i P w ri 11 tickets nt32 eut I, and you'd still have just a 0.17% chanee of winning the jackpot. Makes you think twiee abont buying that ticket, doesn't it? Generalizing a bit, suppose yon want to design a Powethall-ike lottery game where the player chooses k distinct numbers from a set of n numbers, along with bonn number from set of p numbers. The total number of ways this enn be dont is () xp. Within the sume Combinations.java class as the previous problenm, write a main method that allows the user to desigu a lothery guue by eutering values for n, k, and p. Your program should then show the elhnuce of winning the jackpot is that giaw, both in feactieou and percentage form. Be sure to eall your previously written nChoosek thil Here's an example of what your coruplet ed prograu night look like when you run it. Underlined parts indicate what yoi type in as the prograi is running Let's design a lottery game! The numbers shouid range from 1 to what? 69 How sany of those numbers should you pick? And finally, the bonus suaber should range from 1 to vhat? 26 Your chance ofuwinning the jackpot is 1 in 292201338, or 3.4222978130237034E-7% Yeah, good luck with that. Submission Make sure that your Lab6Hk folder contains all your -java files from this assigument. Zip the Lab6HW folder atul submit that zip file to the appropriste dropbox folder in your eCourseware lab sertiot

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago