(40 Marks) Based on UML class diagram presented in Figure 1, you are require to complete the java program source code in

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

(40 Marks) Based on UML class diagram presented in Figure 1, you are require to complete the java program source code in

Post by answerhappygod »

40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 1
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 1 (87.22 KiB) Viewed 24 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 2
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 2 (57.27 KiB) Viewed 24 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 3
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 3 (70.85 KiB) Viewed 24 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 4
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 4 (56.46 KiB) Viewed 24 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 5
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 5 (47.51 KiB) Viewed 24 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 6
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 6 (47.51 KiB) Viewed 24 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 7
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 7 (51.76 KiB) Viewed 24 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 8
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 8 (48.99 KiB) Viewed 24 times
(40 Marks) Based on UML class diagram presented in Figure 1, you are require to complete the java program source code in provided templates. The provided template files as follows, Calculator.java, Coin.java, CoinType.java, CustomerRequest.java, DrinkList.java, DrinkSelling System.java and SystemController.java. DrinkSelling System. java is the program with the Main method to test the functionality of the overall application. PROBLEM SOLVING 0.10 <<enumeration>>>> DrinkList CustomerRequest Use Drink SelingSystem Coin Coin Type 1.4 SystemController Calculator Figure 1: Class diagram As shown in Figure 1 with the respective classes, this program will prompt the user to choose type of drink to buy and enter the numbers of coins to buy. After user enter the coins, the program will produced the updated number of coins. Your program should be able to produce the output shown in Figure 2 or in Figure 3.
WELCOME TO THE XYZ DRINK SELLING Drink available: Price: 150(cents) Price: 180(cents) 1 COKE 2 MILK 3 MILO 4 WATER 5 PEPSI - Price: 200(cents) - Price: 120(cents) - Price: 150(cents) Please select your drink: Please enter coins as follows: pum of 10 cents coins, num of 20 cents coins,num of 50 cents coins,num of 1 Ringgit (100 cents) coins Example: If you would like to enter 2 ten cents coins: 2,0,0,0 Plese enter coins: 2,2,2,3 Your change is :260cents splitted as follows: 1 Ringgit (100 cents) coins: 2 50 cents, coins: 1 20 cents coins: 10 cents coins: 1 Figure 2: Sample Output 1 WELCOME TO THE XYZ DRINK SELLING Drink available: Price: 150(cents) 1 COKE 2 MILK Price: 180(cents) 3 MILO Price: 200(cents) 4 WATER - Price: 120(cents) S PEPSI Price: 150(cents) Please select your drink:- Please enter coins as follows: num of 10 cents coins, num of 20 cents coins, num of 50 cents coins,num of 1 Ringgit (100 cents) coins Example: If you would like to enter 2 ten cents coins: 2,0,0,0 Plese enter coins: 1,2,1,2 Your change is :180cents splitted as follows: 1 Ringgit (100 cents) coins: 1 50 cents coins: 1 20 cents coins: 1 10 cents coins: 1 Figure 3: Sample Output 2 Complete the program based on the following tasks. Note that, the tasks are also stated in the program source code in the given templates. The tasks are labeled as Task I to Task 4. IMPORTANT NOTE: Do not modify existing code in the given templates. Only modify the codes based on the comments/instructions stated in Task I to Task 4.
Task 1: In DrinkList.java; This file contains an enumerated type declaration of DrinkList with a list of coin types and prices. Do the following task, i) Complete the enum declaration using the data stated in Table 1. Drink Type COKE MILK MILO WATER PEPSI EMPTY Table 1: Data to be used in DrinkList enum Selection number 1 2 3 4 5 0 (6 Marks) Price in cents 150 180 200 120 150 0 Note: Constant values of the DrinkList enum is the type of drinks, while the selection. number and price are the fields of each constant value. (12 Marks) Task 2: In CoinType.java, Calculator.java and Coin.java: There is an association relationships among Coin, which is a type of class with CoinType and Calculator classes. Do the following tasks; i) There are errors found in the following statements in Calculator.java. Correct the errors. The method getValue () must be able to functions correctly, to show the association relationship between CoinType and enum Coin //red highlighted texts need modification change.num1Ringgit - remaining Amount / getValue(); remainingAmount remainingAmount & getValue (); change.num50cents Coins remainingAmount / getValue();
remainingAmount = remainingAmount 8 getValue (); change.num20 CentsCoins = remaining Amount / getValue (); remainingAmount = remainingAmount getValue (); change.num10 Cents Coins = remaining Amount / getValue (); remainingAmount = remainingAmount getValue (); ii) There are errors found in the following statements in CoinType.java. Correct the errors. The method getValue () must be able to function correctly, to show the association relationship between CoinType and enum Coin //red highlighted texts need modification total total+this.num10 Cents Coins* getValue (); total = total+this.num20 Cents Coins* getValue (); total total+this.num50 Cents Coins* getValue (); total = total+this.numlRinggit getValue ();
Get Started Ⓒ Calculator.java 1 CoinType.java 1 Ⓒ Coin.java 2 D: > desktop > Program Files > Calculator java > Calculator > calculateChange(int) 1 import java.util."; 2 public class Calculator { 3 4 5 6 7 8 9 10 11 ANASASAARE 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 } public int calculateTotal (CoinType coinsDrop) { return coinsDrop.getTotal(); } public CoinType calculateChange(int amountMoneyToReturn) CoinType change = new CoinType(new int[4]); int remainingAmount amountMoneyToReturn; CustomerRequestjava 1 change.num1Ringgit remainingAmount / getValue(); //code 1 remainingAmount = remainingAmount % getValue(); //code 2 //TASK 2(1): The method getValue() is used to establish association relationship between class Calculator and enum Coin, // correct the statements (code 1-8) below so getValue() can functions correctly. //TASK 4(11): Modify the following statements (code 1, 3, 5 & 7) by using proper ArrayList method change.numsecentsCoins remainingAmount / getValue(); //code 3 remainingAmount remainingAmount % getValue(); //code 4 change.num20CentsCoins remainingAmount / getValue(); //code 5 remainingAmount = remainingAmount % getValue(); //code 6 = change.numdecentsCoins remainingAmount / getValue(); //code 7 remainingAmount = remainingAmount % getvalue(); //code 8 return change; ⒸDrinkList java 2 DrinkSelling System.java 2
Edit Selection View Go Run Terminal Help Get Started ● Calculator.java 1 CoinType.java 1 desktop > Program Files > CoinType.java > CoinType> L public class CoinType ( 2 3 public int num20CentsCoins; public int numsecentsCoins; public int num1Ringgit; Coin.java 2 this.num1ecentsCoins = coinsDrop[0]; this.num20centsCoins coinsDrop[1]; this.numsecentsCoins coinsDrop[2]; this.numiRinggit = coinsDrop[3]; getTotal public int getTotal() int total = 0; //TASK 3(1): change all the int variables numiecentsCoins until numiRinggit into a single ArrayList object declaration public int num10CentsCoins; CoinTypejava-Visual Studio Code Ⓒ DrinkList Java 2 Ⓒ CustomerRequest.java 1 public CoinType(int... coinsDrop) { //TASK 3(11): Modify the statements below to add elements stored in coinsDrop[] with proper ArrayList method DrinkSelling System.java 2 total total+this.num10CentsCoins getValue(); //code 1 total total+this.num20centsCoins getValue(); //code 2 total = total this.nums@centsCoins getValue(); //code 3 total = total this.numiRinggit getValue(); //code 4 return total; //TASK 2(11): The method getValue() is used to establish association relationship between class CoinType and class Coin, //correct the statements (code 1-4) below so getValue() can functions correctly. //TASK 4(1): Modify the following statements below using ArrayList method (code 1-4)
Started Calculator.java 1 CoinType.java 1 Ⓒ Coin.java 2 esktop > Program Files > Calculator.java > Calculator > calculateChange(int) import java.util."; public class calculator { public int calculateTotal (CoinType coinsDrop) { return coinsDrop.getTotal(); } public CoinType calculatechange(int amountMoneyToReturn) CoinType change = new CoinType(new int[4]); int remainingAmount amountMoneyToReturn; CustomerRequestjava 1 change.numsecentsCoins remainingAmount / getValue(); //code 3 remainingAmount = remainingAmount % getValue(); //code 4 //TASK 2(1): The method getValue() is used to establish association relationship between class Calculator and enum Coin, // correct the statements (code 1-8) below so getValue() can functions correctly. //TASK 4(11): Modify the following statements (code 1, 3, 5 & 7) by using proper ArrayList method change.num1Ringgit remainingAmount / getValue(); //code 1 remainingAmount = remainingAmount % getValue(); //code 2 change.num20centsCoins remainingAmount / getValue(); //code 5 remainingAmount = remainingAmount % getValue(); //code 6 Drinklist java 2 change.num18centsCoins remainingAmount / getValue(); //code 7 remainingAmount = remainingAmount % getValue(); //code 8 return change; DrinkSellingSystem
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply