Question: The question covers concepts in all the seminars. Apply data structures to store and process information. Employ structure programming and use of functions to make
The question covers concepts in all the seminars. Apply data structures to store and process information. Employ structure programming and use of functions to make the program modular. MonkeyPrint is a company that provides shirt embroidery services. The prices (in cents) for sewing characters onto clothing are shown in Table 4-1. For example, the price of sewing an uppercase H is 45 cents and a lowercase a is 63 cents. Characters not found in Table 4-1 cannot be embroidered. Pricing for font size 24pts =========================== A 44 B 79 C 60 D 56 E 46 F 50 G 65 H 45 I 38 J 49 K 51 L 36 M 48 N 55 O 56 P 53 Q 41 R 58 S 65 T 36 U 23 V 49 W 46 X 48 Y 54 Z 52 a 63 b 55 c 37 d 55 e 63 f 58 g 40 h 31 i 35 j 50 k 51 l 36 m 32 n 58 o 50 p 55 q 55 r 53 s 61 t 57 u 37 v 33 w 59 x 53 y 54 z 39 ! 36 & 65 * 65 $ 65 # 64 . 30 , 36 < 38 > 38 ? 45 @ 65 Table 4-1
The pricing above applies to standard font size 24 pts, while font size 36 pts will cost 1.5 times and font size 48 pts will cost 2 times. Both the characters pricings and the fonts pricings are stored in files, as these can change anytime. (See Appendix A) (a) Write the following functions. (i) readPricing(filename: string, pricing: dictionary) where the parameter is a string representing the filename that the pricing is stored. This function reads the file and store the keys and values into the given dictionary. The keys are the characters, and the values are the pricings. Using readPricing(), we can setup the characters pricing dictionary and fonts pricing dictionary, by providing the appropriate filenames. (ii) showPricing(charPricing: dictionary, fontPricing: dictionary, fontSize: int) that will display the characters pricing similar to Table 4-2, and according to the parameter fontSize. For example, if fontSize is 36 pts, then the characters pricing is multiplied by 1.5 times. Hence the Table 4-2 should be the display from showPricing(). Note that the prices must be rounded to the nearest integer. You can decide how many characters and pricings to display on each row, as long as the pricing table is aesthetically presented. Pricing for font size 36pts =========================== A 66 B 118 C 90 D 84 E 69 F 75 G 98 H 68 I 57 J 74 K 76 L 54 M 72 N 82 O 84 P 80 Q 62 R 87 S 98 T 54 U 34 V 74 W 69 X 72 Y 81 Z 78 a 94 b 82 c 56 d 82 e 94 f 87 g 60 h 46 i 52 j 75 k 76 l 54 m 48 n 87 o 75 p 82 q 82 r 80 s 92 t 86 u 56 v 50 w 88 x 80 y 81 z 58 ! 54 & 98 * 98 $ 98 # 96 . 45 , 54 < 57 > 57 ? 68 @ 98 Table 4-2 (10 marks) (b) Write an application that manages the Embroidery Services for MonkeyPrint. The following points will detail the setup and functionalities required for this application. Before presenting the Main Menu (Table 4-3), your application needs to load the characters and font sizes pricings using the 2 given files in Appendix A.
MonkeyPrint Embroidery Services =============================== 1. Display Pricing Table 2. Request for Quote 3. Add/Update Characters Pricings 4. Add/Update Font Sizes Pricings 0. Exit Enter selection: _ Table 4-3 Selection 1 - Display Pricing Table will prompt the MonkeyPrint admin for a font size. o Display the characters and their pricings, similar to Table 4-1 or 4-2, only if the font size is valid. Selection 2 Request for Quote allows the MonkeyPrint admin to check the embroidery pricing by entering a string and a desired font size. o Pricing can only be computed if all characters can be found in the characters pricing dictionary, and the font size is valid. o Otherwise, display appropriate message and return to Main Menu. o When customer spent more than $8 at MonkeyPrint embroidery services, customer can enjoy 5% discount or get the lowest priced character free. o Your program will compute and display the best discounted price for the customer. For example: MonkeyPrint Embroidery Services =============================== 1. Display Pricing Table 2. Request for Quote 3. Add/Update Characters Pricings 4. Add/Update Font Sizes Pricings 0. Exit Enter selection: 1 Request for Quote ================= Enter characters: Roger Federer is peRFect Enter font size: 24 Pricing: $11.43 After 5% discount: $10.86 MonkeyPrint Embroidery Services =============================== 1. Display Pricing Table 2. Request for Quote 3. Add/Update Characters Pricings 4. Add/Update Font Sizes Pricings 0. Exit Enter selection: 1
Request for Quote ================= Enter characters: @$SSSs&sSSS$@ Enter font size: 24 Pricing: $8.37 After 1 free character: $7.76 Selection 3 - Add/Update Characters Pricings will perform the following: o Prompt the MonkeyPrint admin for a character. o If the character is not found in the dictionary, prompt user for the pricing. The character and pricing are added to the characters pricing dictionary and also the file. o If the character is found in the dictionary, display the current pricing, then further prompt for the new pricing. Update the pricing into the characters pricing dictionary and also the file. Selection 4 - Add/Update Font Sizes Pricings will perform the following: o Prompt the MonkeyPrint admin for the font size. o If the font size is not found in the dictionary, prompt user for the pricing ratio. The font size and pricing ratio are added to the font sizes pricing dictionary and also the file. o If the font size is found in the dictionary, display the current pricing ratio, then further prompt for the new pricing ratio. Update the new pricing ratio into the font sizes pricing dictionary and also the file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
