Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Background The local chocolate factory is going to try a curry flavoured dark chocolate. They need to trial the amount of curry which they
Background The local chocolate factory is going to try a curry flavoured dark chocolate. They need to trial the amount of curry which they add so that the best flavour can be determined. This concentration can range from no curry-all chocolate (represented numerically as 0.0) up to all curry-no chocolate (represented numerically as 1.0). Banana is sometimes eaten with curry to reduce the 'heat' of the flavour. The chocolatier plans to add very small banana pieces to the chocolate too. The amount needs to be determined to match the curry and this will be trialled for a defined range too. Modelling will be used to simulate the trials of different amounts of curry and banana to optimise taste. To reduce cost, a 'sweet spot' of 500 Sweet Flavour Accents (SweetFAs - the well-known international standard unit) has been set as the target. Once a combination of curry, banana, and dark chocolate reaches/exceeds 500 SweetFAs the trial will conclude. The food scientists have derived an equation for the tastiness of the chocolate: Banana factor = 120-number of banana pieces Flavour = curry concentration* (800 - (banana factor* banana factor)) Program specification You and your partner must write a Java program to calculate and display all possible flavours for a range of banana pieces and curry concentrations. First, your program should obtain the following information from the user: the minimum number of pieces of banana desired to be included; the maximum number of pieces of banana desired to be included; and a step size for the curry concentration 1/5 Once these values have been entered the program should check if the values entered are legal (all positive, the minimum less than or equal to the maximum, and with the difference between the minimum and maximum number of banana pieces not exceeding 10). If the values entered are not legal (range checks only - you don't have to detect incorrect types), the program should print an error message. If the values entered are valid, the program should produce a table of results displaying the flavour of the chocolate for each possible number of banana pieces in the range specified by the user. Each column in the table should show the results for a specific number of banana pieces, and should have this number displayed at the top of the column. Each row in the table should show the results for a particular curry concentration step, and should have that value displayed on the left to 2 decimal places. The first row should have a curry concentration equal to the step size given by the user, and the curry concentration should increase by that step size for each subsequent row. The program should keep adding rows to the table until either the curry concentration reaches/exceeds 1.0, or until a chocolate bar is produced reaching the threshold flavour of 500 SweetFAs. All calculations of flavour should be done using doubles, and the results should be displayed to 1 decimal place. Your solution should run in Dr Java and comprise the following files: SweetFAInterface.java and Sweet FA.java - the Flavour ADT. You should have the following methods: a constructor, "getters' and 'setters' for the curry concentration object and number of banana pieces, and 'doer' methods to calculate the flavour, determine whether the flavour exceeds the threshold, and convert the flavour to each of a double and a String. CurryInterface.java and Curry.java - the specification and implementation (respectively) of a curry concentration. A curry concentration should be implemented as a class with instance variables which consist of: o the current curry concentration value (as a double); and o the curry step value (as a double). The class should also contain methods as specified in the interface, i.e. a constructor, setter and getter for the step value, getter for the concentration value, a doer which checks whether the concentration value is at the maximum (and if so returns false, and if not increases the concentration value by the step and returns true), and a method to convert the concentration value to a String. AssigOne122.java - the file which contains the main () method. A starting point is available on MyLO for you to download. You should complete all the required files. Two example executions are shown below: The Local Chocolate Factory Enter the minimum number of banana pieces: 100 Enter the maximum number of banana pieces: 200 Enter the curry concentration step size: 0.14 Sorry, these are not legal. The Local Chocolate Factory Enter the minimum number of banana pieces: 102 Enter the maximum number of banana pieces: 109 Enter the curry concentration step size: 0.14 Curry 0.14 0.28 0.42 0.56 Number of banana pieces 102 103 104 66.6 71.5 133.3 143.1 76.2 80.5 152.3 161.0 253.7 322.0 338.2 199.9 214.6 228.5 241.5 266.6 286.2 304.6 0.70 333.2 357.7 380.8 402.5 422.8 399.8 429.2 457.0 483.0 507.4 0.84 105 106 84.6 169.1 107 108 88.3 91.8 176.7 183.7 265.0 275.5 353.4 367.4 441.7 459.2 530.0 551.0 every do, for, and while loop should have a block of code (ie. {}s) the keyword continue should not be used 109 95.1 190.1 Program Style Your program should follow the following coding conventions: final variable identifiers should be used as much as possible, should be written all in upper case and should be declared before all other variables variable identifiers should start with a lower case letter every if and if-else statement should have a block of code (i.e. collections of lines surrounded by (and )) for both the if part and the else part (if used) 285.2 380.2 o Each variable declaration should be commented 475.3 570.4 the keyword break should only be used as part of a switch statement opening and closing braces of a block should be aligned all code within a block should be aligned and indented 1 tab stop (or 4 spaces) from the braces marking this block instance variables should be used sparingly with parameter lists used to pass information in and out of functions local variables (excluding loop counters) should only be declared at the beginning of methods (either as parameters or otherwise) commenting: There should be a block of header comment which includes at least file name student names student identity numbers a statement of the purpose of the program . date the percentage of the work completed by the authors - 50:50 is expected and assumed but reasons should be given if it is more/less than this 3/5 There should be comments that identify groups of statements that do various parts of the task o Comments should describe the strategy of the code and should not simply translate the Java into English
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started