ISOM 2007 - Programming for Business Analytics
2023/2024 (First Semester)
Assignment 1
Due date: November 3, 2023 (in class)
Instructions:
-
Read the Assignment Requirements posted in the UMMoodle before attempting to solve the following problems with Python programs.
-
Both the hardcopy and softcopy of your assignment should be submitted on time. All programs (.ipynb files) are to be compressed and uploaded to the UMMoodle under the “Submit Assignment 1” button. The compressed file should be named with your student number such as “ba12345_Ass1.zip”.
Question 1: Reverse Text (20%)
Write a Python program that outputs a greeting message at the beginning, then reads a string of text and displays the text in reverse order. If the last character is a punctuation mark, it should remain as the last character. Your program should allow the user to choose to continue or not. It will also output a message to end the program.
Sample Input & Output:
=================================
Welcome to the Reverse Program! =============================== Please enter a word or a sentence: Hello The reversed form of Hello is Would you like to continue (Y/y for Yes, N/n for No)? Y ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please enter a word or a sentence: The reversed form of Good morning! is Would you like to continue (Y/y for Yes, N/n for No)? n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thank you very much!
olleH
Good morning!
gninrom dooG!
P.1
Question 2: Personal Loan (40%)
The manager of a certain bank needs to make decisions on granting personal loans to the customers. He/she will need a program to help to check the duration of the loan. For example, if the customer wishes to borrow $100,000, with the annual interest rate 3.6% p.a., and he/she could afford to pay back $1,000 per month (principal plus interest) to the bank, the manager has to tell the customer the exact duration of the loan and the remaining balance to be repaid in the last month.
The interest is computed by multiplying the annual interest rate to the current value of the loan, divided by 12 months (e.g. for the first month, multiply $100,000 by 0.036, divided by 12, the interest for the first month will then be $300.) The repaid principal amount for the first month will then be $700 (which comes from the difference between the repayment amount $1,000 and the interest $300). This repaid principal amount $700 will be deducted from the current value of the loan monthly, leaving the loan to become less and less. Therefore, the current value of the loan for the second month will be $99,300, and the interest will be $297.90 (correct to 2 decimal places), leading to a repaid principal amount of $702.10 (correct to 2 decimal places).
Write a Python program that will accept 3 values: the amount of the personal loan, the annual interest rate charged by the bank, and the monthly payment of the customer. The program should display a table listing all the monthly installments that the customer has to repay the bank, until the remaining balance is less than the monthly payment. It should also calculate the current monthly face value of the loan, the monthly interest payment and the monthly repaid principal as shown below.
Sample Input & Output:
===================================
Welcome to the Personal Loan System
===================================
Please enter the loan amount
Please enter the annual interest rate(%)
Please enter the monthly payment
Month Current face value Interest ==============================================================
: 100000 : 3.6 : 1000
1 $ 100,000.00 2 $ 99,300.00 3 $ 98,597.90
$ 300.00 $ 700.00 $ 297.90 $ 702.10 $ 295.79 $ 704.21
......... ............
......... ............
Remaining Balance in month 120 =
(Note: The remaining balance will be settled in the last
month!)
$69.78
Repaid Principal
$69.78
P.2
Question 3: Sales System (40%)
At Christmas sales period, a clothing store advertises that if the customer buys a suit, he/she can get a second suit at 50% off. That means, if the customer buys two suits, the lower priced suit will be reduced by 50%. If three suits were bought, only the lowest priced suit will be reduced by 50%. If four suits were bought, the lowest and the second lowest priced suits will be reduced by 50%. If the customer only purchase a single suit, a discount of 10% off will be applied.
Assume that one customer could only purchase a maximum of 4 suits, write a Python program that will print the invoice showing the sales transactions, by asking the salesgirl to input the sales tax, the number of purchased items, and the retail prices of the purchased suits one by one. The program will help to calculate the total price after considering the sales promotion of 50% off on the second item as advertised. In addition, the sales tax will be applied to the finalized retail price of each item. The total price will be rounded to the nearest dollar, without charging any extra cents (e.g., if the calculated total price is $1,311.975, the total price being charged will be $1,311.00 only).
Sample Input & Output:
===========================
Welcome to the Sales System
===========================
Please enter sales tax in %
Number of purchased items
Retail Price for item 1
Retail Price for item 2
-----------------------------------------
Less: Discount applied :-$
Total price before tax : $
Total price after tax (5%) : $
-----------------------------------------
Need to print the invoice? (Y/N) Y
-----------------
| Sales Invoice |
-----------------
Item Retail Price Discount Sales Tax Total Price
====================================================================
1 $ 499.00 $ 249.50 $ 12.47 $ 261.97
2 $ 1,000.00 $ 0.00 $ 50.00 $ 1,050.00
====================================================================
Total price after tax: $1,311.00
================================
Do you wish to continue? (Y/N) Y
=========================== Welcome to the Sales System =========================== Please enter sales tax in % : 6
: 5
:2
Item Retail Price Discount Sales Tax Total Price ====================================================================
1 $ 499.00 2 $ 1,000.00 3 $ 800.00
$ 249.50 $ 0.00 $ 0.00
$ 14.97
$ 60.00
$ 48.00
$ 264.47 $1,060.00 $ 848.00
: 3
: $499
: $1000
: $800
249.50
2049.50
2172.00
====================================================================
Total price after tax: $2,172.00
================================
Do you wish to continue? (Y/N) Y
===========================
Welcome to the Sales System
===========================
Please enter sales tax in %
Number of purchased items
Retail Price for item 1
Retail Price for item 2
Retail Price for item 3
Retail Price for item 4
-----------------------------------------
Less: Discount applied :-$
Total price before tax : $
Total price after tax (5.5%): $
-----------------------------------------
Need to print the invoice? (Y/N) Y
-----------------
| Sales Invoice |
-----------------
Item Retail Price Discount Sales Tax Total Price
====================================================================
1 $ 500.00 2 $ 1,000.00 3 $ 699.00 4 $ 1,200.00
$ 250.00 $ 0.00 $ 349.50 $ 0.00
$ 13.75
$ 55.00
$ 19.22
$ 66.00
$ 263.75 $1,055.00 $ 368.72 $1,266.00
: 5.5
: 4
: $500
: $1000
: $699
: $1200
599.50
2799.50
2953.00
====================================================================
Total price after tax: $2,953.00
================================
Do you wish to continue? (Y/N) N
Thank you!
P.4
Bonus Question (10%)
Follow-up of Question 3: After a week of the sales promotion, it was found that many customers split their purchases into pair of two items which increased the burden of the salesgirls and the sales figures were not satisfactory. The manager therefore decided to change the promotional terms a little bit. That is, if the customer buys one suit, the promotion terms remain unchanged (i.e. 10% off for the item). If the customer buys two suits, the lower priced suit will be 50% off while the higher priced suit will be 10% off. If the customer buys 3 suits, the highest and the lowest priced suit will be 10% off while the second highest priced suit will be 50% off. If the customer buys 4 suits, the second highest priced suit and the lowest priced suit will be 50% off, while the highest and the third highest priced suit will be 10% off.
Write a program that repeated Question 3, with the new promotional terms stated above. The required format of the program input and output will be similar to Question 3.
P.5