This project sometimes takes students many, many hours. Please promise yourself that you will reach out to the CS Tutors or your instructor for help if you have already spent 10 or more hours on the project or if you have been stuck for more than 1 hour.
For this project, you get to build off of the FrozenYogurt class from Project 2 and exercise using loops in Java! A very common application of loops is input validation. You will get to do that in this project. Additionally, you get to use either a StringBuilder or StringBuffer object to store multiple toppings in a FrozenYogurt object.
Building off of the requirements for the FrozenYogurt class in Project 2 make the following changes to that class:
ALERT: Unable to set <name>'s price to <price> (negative values are not allowed)Where <name> is the name of the frozen yogurt and <price> is the parameter's value. If the price is 100.0 or greater, do not update the price and return a String with the following value:
ALERT: Unable to set <name>'s price to <price> (value is too high (>=100.00))Otherwise, update the price and return an empty string. Note, do not put this logical in the driver code. Put it in your FrozenYogurt class.
ALERT: <new yogurt flavor> is not one of the valid yogurt flavors (chocolate or vanilla)!Where <new yogurt flavor> is the value of the parameter. If the new flavor is valid, then return an empty string.
For this project, write a main() method in a FrozenYogurtDriverWithMixins class so that it completes the following (in the order given).
Sorry, "<text entered>" is neither yes nor noWhere <text entered> is the user's input. Repeatedly ask the user until either "yes" or "no" is entered. Note, repeat the prompt with the phrase "add a frozen yogurt" each time the user is prompted to enter the name of the yogurt.
Allow the yogurt base flavor and topping names to be multiple words (to accomplish this, you probably want to use only calls to nextLine on your Scanner object to get input from the user. To get the price, pass the string that nextLine returns to the parseDouble method in the Double class to get a double from the inputted String).
Write Javadoc for this class and Javadocs for each method as well.
codePost does not support the package statement. If your IDE inserted one, I configured codePost to automatically remove it.
Welcome PUT YOUR ORIGINAL WELCOME MESSAGE HERE Would you like to add a frozen yogurt (yes/no)? maybe You entered: maybe Sorry, "maybe" is neither yes nor no Would you like to add a frozen yogurt (yes/no)? deciding You entered: deciding Sorry, "deciding" is neither yes nor no Would you like to add a frozen yogurt (yes/no)? yes You entered: yes Please enter the name of the frozen yogurt: Berry Delight You entered: Berry Delight Please enter the price for the Berry Delight: -50.0 You entered: -50.0 ALERT: Unable to set Berry Delight's price to -50.0 (negative values are not allowed) Please enter the price for the Berry Delight: 999.99 You entered: 999.99 ALERT: Unable to set Berry Delight's price to 999.99 (value is too high (>=100.00)) Please enter the price for the Berry Delight: -1.0 You entered: -1.0 ALERT: Unable to set Berry Delight's price to -1.0 (negative values are not allowed) Please enter the price for the Berry Delight: 4.5 You entered: 4.5 Please enter the base yogurt flavor for Berry Delight: Blueberry You entered: Blueberry ALERT: Blueberry is not one of the valid yogurt flavors (chocolate or vanilla)! Please enter the base yogurt flavor for Berry Delight: blueberry You entered: blueberry ALERT: blueberry is not one of the valid yogurt flavors (chocolate or vanilla)! Please enter the base yogurt flavor for Berry Delight: vanilla You entered: vanilla Please enter the topping to add to Berry Delight: blueberries You entered: blueberries Would you like to add another topping frozen yogurt (yes/no)? thinking You entered: thinking Sorry, "thinking" is neither yes nor no Would you like to add another topping frozen yogurt (yes/no)? still You entered: still Sorry, "still" is neither yes nor no Would you like to add another topping frozen yogurt (yes/no)? thinking You entered: thinking Sorry, "thinking" is neither yes nor no Would you like to add another topping frozen yogurt (yes/no)? yes You entered: yes Please enter the additional topping flavor: blackberries You entered: blackberries Would you like to add another topping frozen yogurt (yes/no)? yes You entered: yes Please enter the additional topping flavor: strawberries You entered: strawberries Would you like to add another topping frozen yogurt (yes/no)? no You entered: no Frozen Yogurt : Berry Delight Price : $5.48 Yogurt : vanilla Topping(s) : blueberries, blackberries, strawberries Thank you!
Notice that multiple invalid values are entered and that the program keeps asking for a valid values until it gets a valid one. Also notice that all money values displayed by the program are rounded to two decimal places.
Welcome PUT YOUR ORIGINAL WELCOME MESSAGE HERE Would you like to add a frozen yogurt (yes/no)? yes You entered: yes Please enter the name of the frozen yogurt: Raspberry Cheesecake You entered: Raspberry Cheesecake Please enter the price for the Raspberry Cheesecake: 5.5 You entered: 5.5 Please enter the base yogurt flavor for Raspberry Cheesecake: vanilla You entered: vanilla Please enter the topping to add to Raspberry Cheesecake: raspberries You entered: raspberries Would you like to add another topping frozen yogurt (yes/no)? yes You entered: yes Please enter the additional topping flavor: crackers You entered: crackers Would you like to add another topping frozen yogurt (yes/no)? no You entered: no Frozen Yogurt : Raspberry Cheesecake Price : $5.99 Yogurt : vanilla Topping(s) : raspberries, crackers Thank you!
Welcome PUT YOUR ORIGINAL WELCOME MESSAGE HERE Would you like to add a frozen yogurt (yes/no)? nah You entered: nah Sorry, "nah" is neither yes nor no Would you like to add a frozen yogurt (yes/no)? never You entered: never Sorry, "never" is neither yes nor no Would you like to add a frozen yogurt (yes/no)? no You entered: no Thank you!
Points Item ---------- -------------------------------------------------------------- _____ / 15 Style + Code is indented correctly + Methods should be no longer than 1 page + Documentation: (written for another software developer) * All source code files include Javadoc header block with description, @author, @version, etc. * Javadoc (with block tags, for example @param, @return) before each method * All non-trivial variables are commented * Comments included before major portions of code _____ / Compiles (max of 50% if it doesn't compile) _____ / 83 codePost tests _____ / 5 Complete HTML documentation (bonus) _____ / 5 Submitted 1+ days early (bonus) _____ / 2 Completed rubric (estimates for each line including hours spent) _____ /100 Total _____ Approximate number of hours spent I, (REPLACE WITH YOUR FULL NAME), affirm that the code that I submitted is my own work and that I did not receive help that was not authorized by the instructor.
Copy and paste this rubric into a rubric-FrozenYogurtWithMixins.txt file (not a .docx, .doc nor .rtf file). Think of this as a checklist to ensure that you receive the maximum points possible. For each grade item, fill in your estimate for the grade you deserve. Additionally, include your estimate of how many hours your spent. Lastly, replace, "(REPLACE WITH YOUR FULL NAME)" with your full name to indicate that what you are submitting is entirely your own work.
The submission process has two parts:
Submit your FrozenYogurt class and your FrozenYogurtDriverWithMixins class to codePost.io.
To register for a free codePost account, please follow these instructions.
You can submit to codePost multiple times if you want.
Only your last submission will be graded.
Watch this short video for a demonstration of submitting an assignment and reviewing the results:
Submit your rubric-FrozenYogurtWithMixins.txt to the appropriate Assignment tab/folder in CougarVIEW. This is required to receive detailed graded feedback on your project. If you resubmit your rubric, this will effectively replace your previous submission.
String professorsLastName = "Carroll"; String professorsLastNameMispelled = "Carrol"; if( professorsLastName.equals( professorsLastNameMispelled ) == true ){ System.err.println("Something wrong happened!"); }
// Prompt user // Read input from user // echo input (helpful for knowing what the autograder entered) while( invalid_input_expression ){ // Display error message // Prompt user // Read input from user // echo input (helpful for knowing what the autograder entered) }Alternatively, you could express the while loop as follows:
while( !( valid_input_expression ) ){