COMP 1900 - Spring 2019 Lab 2 Homework Total Points: 12 As with all otber labs, this should be done individually. Contact your instructor and/ or vt Computer Science Learning Center (ttpe:/www.sesphis.edu you need help. You may also work with other studeuts on general solutiou //www.menphis.edu/cs/current-students/calc.php) f submit must be your own. Due: By the beginning of your next lab session. Grader: Your lab TA will grade your work. Questious about grading should be directed to hiu/her. TA contact info can be found on the course syllabus. Coding Style: Use consistent indentatiou in your code; include a reasonable amount of comue CONSTANT NAMES. Your TA may dedact points for poor coding style. Within the 1900 folder on your desktop, create a new folder named Lab2HWLastnaneFirstnase. (4 pts) Problem 1 a reasonable amount of comueuts your code; and use standard Java conventions for Class Names, In class, we wrote a program that solves quadratic equations of the form az, bz + c people are aware that a formula also exists to solve cubic equations of the form 0. Not n It can be shown that any cubic equation in the general form az +bz2 + er tde to the form of equation (1). Equation (1) is solvable using Cardano's d 0 can be reduced formula, named after the Italian mathematician who allegedly derived it during the 1500s. The fortnula states hatthes 4 27 For now, let's worry only about the real values of the quantities in (2). This means t you only one of the three roots to (4). Within your Lab2HW folder, write a program named CubicSolver. java that allons values (potentially including decimals) for the coefficients p aad q from (1). Your compute and display the value of the solution z according to (2). Note that ahould with an exponent of 1/3 works for computing cube roots of positive numbers, Math h using Math aN when computing the cube root of a negative number. Use Math.cbrt instcad Here's an example of what your completed program might look like when you indicate what you type in as the program is running. the user to enter program then esitive numbers, Math.pow gives a result of run it. Underlined parts What is the value of p? What is the value of q The solution xis-2.9999999999999742. (4 pts) Problem 2 United States, phone numbers are comprised of a 3-digit area code followod by a7-digit uumber. Area codes of 800, 688, 877, 866, 85, and 844 denote toll free numbers (se httpe ://www.fcc. gow consusers/guidea/what-toll-tree-nusber-and-hov-does-it-vork). Withia your Lab2HW folder, a 10-digit U.S. phone number us a single integer. Your program sbould then print whether ut not that write a program named TollFreeNusbers.java that allows the user to euter number is toll-free. Here parts indicate what you type in as the program is running. Enter a 10-digit phone number (no spaces or dashes): TT575309 That nunber is toll-freet are two examples of what your completed program might look like when you run it. Underlined Enter a 10-digit phone nusber (no spaces or dashea) : 9018675309 That auaber is not toll-free! Hints . The int data type only stores values up to 23 1, which works out to 2,147,483,647. Thns, most 10-digit sumbers will not be storable as int values. Instead, use the long data type. long hehavcs the same as int but uses twice the memory to store its values (64 bits vs. 32 bits), giving it a maximum value of 243-1. Use nertLong to read a long value from the user Since the user enters the phone number into a single variable, can you use integer division and/or mod to get the area code by itself? (4 pts) Problem 3 Suppose you're throwing a wild party for yourself and 9 of your closest friends. Since this purty is wild. you expect each person ( to disappoint any of your friends (or yourself), so you need to make sure there's enough strawberry juice available: 10 people x 14 cans/person 140 cans. But you can't just buy strawberry juice in individual cans - it's sold oaly in 6-packs. Thas, you need to buy at least 24 of those 6-packs (giving you a total of 144 cans) to satisfy everyone. The extra 4 cans can be saved for next time, or perhaps used as an incestive to encourage your guests to help you clean up afterward. yourself) to drink 14 cans of uh... strawberry juice. You don't want After throwing several of these parties, you're getting tired of doing the math yourself every time. Let's do the computer scientist thing and gencralize the problem so we can write a program to solve it. You want to throw a party for f friends, each of whoun will drink c cans of a wholesotue, bealthy beverage which is sold only in p-packs. (As before, assume that you'll partake in the drinking yourself too.) Within your Lab2Hu folder, write a program named PartyPlanner java that reads user input for f, c. and p. The program should then report the minimum with the sumber of extra cans (if any) that you'll bave. The program should also allow you to enter the name of the drink (as a string) and include that name in its results. t number of p-packs that need to be bonght, along Here's an example of what your completed program might look like when you run it. Underlined parts indicate what you type in as the program is running Party Planner Pro v1.0 How nany friends are you throving this party for? What is the drink of choice? aice Row rany cans vill each person drink? Hou sany cana are sold per pack? The minimus parchase is 24 6-packs of stravberry juice, which will satisfy everyone and leave 4 extra can(s). Hint: There are some scenarios in which you can buy exactly the desired number of cans, with no extra cans. Are the calculations different for these scenarios? Use an if statement to deternine whether there are extra cans. Submission sure that your Lab2BM folder coatains all your java files from this assignment. Zip the Lab2Hw folder and submit that ip fle to the appropriate dropbox folder in your eCoursewarc lab setion