Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you the price. Sounds like a surefire formula for s pricc is $238 per year 've started Subprime, a competitor to Amazon Prime that

image text in transcribed
image text in transcribed
image text in transcribed
Suppose you the price. Sounds like a surefire formula for s pricc is $238 per year 've started Subprime, a competitor to Amazon Prime that offers half the benefits for double ccess! Auazou Prime costs $119 per year. so Subpriue's service efforts, you offer prorated refunds of the annual price wheu customers As part of your customer cancol their Subpriune servicc. Your policy is that all the rcmaining days of the year (excluding the day f cancollation) arc included in tlhe refund. For cxample, a customer wio caucels ou Jan. 1. 2019 would lhave 364 unused days and thus get a rofuud of 364/365 x $238 S237.35. A customer who caneels on D c. 31, 2019 would have 0 unuscd days and thus get a rcf1111d of 0/365 $238 . S0.00. (Yim lout believe in holiday checr.) Seeus simple euough, right? Unfortunately, the calculations above will be a little off lnext year since 2020 is a lcap ycar and has ouc extra day. Uh oh. Lct's tackle this problem with METHOD POWERTMI Within the 1900 folder on your desktop, creatc a new folder uamed Lab6LastnameFirstname. Within vour Lab6 folder, creatc a new class named RefundsGalore.java. Within that class. write the following mctlhods. Note that user input should be rcad only in the main method at the end! The other methols get thieir infornation from their parancters. 1. (2 pts) public static boolean isLeapYear(int year) This method should return whether the year paramcter is a leap year. Leap ycars are years that arc divisiblc by 4, cxccpt thosc that arc also divisible by 100. But therc's also an exception to the exception: ycars tlhat arc divisible by 400 are lcap ycars. Here arc some cxample arguments for the isLeapYear nethod and their cxpeeted retur valies: Argument Rcturn Valuc 2019 2020 2100 2400 falsc truc falsc truc month, int year) 2. (3 pts) public static int daysInNonth(int this method should return the number of days in the specified sonth of the specifed year. Yotu can assune the sonth paraneter has a valuc between 1-12. Call your previonsly written methols as neodcdd Romember that April, Junc, September, and Noveimber have 30 days. February has 20 days in a lcap ycar, or 28 days otherwisc. All other months have 31 for the daysIaMonth method and their expoctod returnu valucs: days. Here are souie exauuple cturu (2. 2020) (11, 2019) (12. 2020) 29 30 3. (5 pts) public static double fraction0fYearRemaining(int sonth, int day, int year) This method should return the fraction of the year renaining (expressed as a decimal) starting from the specified month and day, excluding the starting day itself. You ean asstune the month paraumctor has a value bctwoon 1-12, and the day paraucter has a valid value for thc given month and year. Call your previously written mcthods as ucoded. Here are some example arguments for the fractionofYearRemaining method and their expected return valucs Arguments Return Valuc otcs On Jan. 1. there are 364 days renaining 364/365 0.9972602739726028 2019 isn t a lcap ycar, so there are 305 total days On Dec. 31. there are 0 days reumaining (1, 1, 2019) 0.9972602739726028 (12, 31, 2019) 0.0 0. -0.0 On Jan. 1. there are 365 days remaining. 365/366 0.9972677595628415 2020 is a lcap ycar, so thiere are 360 total days. On Apr. 3, 31 +29+31 +3 94 days have passerl. so there arc 366-94-272 days remainiug 272/366 0.7431693989071030 (1, 1, 2020) 0.9972677595628415 (4, 3, 2020) 0.7431693989071039 4. (5 pts) public static void main(Stringl args) Finally, the main mcthod should allow the user to cnter thrce inputs: thie nouth, day. aud the cancellation datc. Call your previously writteu methods to comptte anud show the aunomit of the prorated refund for that datc. our main method should also include a loop that checks the user input to custure it's valid. Valid imput mcans the month is betwoen 1-12, the ycar is at lcast 2019. and the day is cousisteut with the mouth and ycar. (For cxample, 29 is not a valid day if the mouth is Fcbruary aud it's not a agail. Ica p ycar.) If the user enters an invalid datc, show an crror mcssage aud ask him/her to try again This should be donc as many timcs as ncccssary Here's au oxanuple of what your compiesed prugram might look like when program might look like when you ruu it. Underlisued parts ruuning. indicate what you type in as the program is When did you cancel your Subprise service? Month: 2 Day: 29 Year: 2012 Sorry, 2/29/2019 doesn't appear to be a valid date Month: 2 Day: 22 Year: 2016 Sorry, 2/29/2016 doesn't appear to be a valid date. Care to tr Month: 4 y again? Day: 3 Year: 2020 fund of $176.87431693989072. Thanks for OK, you'11 be issued a prorated re Subprise - disappointing customers since 2019! using Submission folder contaius all your -java files from this assigunent. Zip tlue Lab6 folder Make sure that your Lab6 and submit that zip file to the appropriate dropbox folder in your cCours eware lab scction

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

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

=+employee to take on the international assignment?

Answered: 1 week ago

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago