diff --git a/tasks/task-03/HarshitRSethi/calculator.cpp b/tasks/task-03/HarshitRSethi/calculator.cpp new file mode 100644 index 0000000..bd8c8c8 --- /dev/null +++ b/tasks/task-03/HarshitRSethi/calculator.cpp @@ -0,0 +1,55 @@ +#include +using namespace std; + +/* + Function: calculateFinalAmount + Purpose : Calculates final payable amount after tax and discount. +*/ + +double calculateFinalAmount(double amount, int customerType) +{ + // Part A + if (amount <= 0) + { + cout << "Invalid amount" << endl; + return -1; + } + else + { + double tax = (amount / 100) * 18; + double total = tax + amount; + + // Part B + // Discount based on customer type + + if (customerType == 1) + { // Regular Customer + total = total * 0.95; // 5% discount + } + else if (customerType == 2) + { // Premium Customer + total = total * 0.85; // 15% discount + } + return total; + } +} + +int main() +{ + double amount; + int type; + + cout << "Enter bill amount: "; + cin >> amount; + + cout << "Enter customer type (1-Regular, 2-Premium): "; + cin >> type; + + double payable = calculateFinalAmount(amount, type); + if (payable == -1) + return 1; + + cout << "Final Payable Amount: " << payable << endl; + + return 0; +} diff --git a/tasks/task-03/calculator.cpp b/tasks/task-03/calculator.cpp deleted file mode 100644 index 4a4dd07..0000000 --- a/tasks/task-03/calculator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -using namespace std; - -/* - Function: calculateFinalAmount - Purpose : Calculates final payable amount after tax and discount. -*/ - -double calculateFinalAmount(double amount, int customerType) { - //Part A - - - //Part B -} - -int main() { - double amount; - int type; - - cout << "Enter bill amount: "; - cin >> amount; - - cout << "Enter customer type (1-Regular, 2-Premium): "; - cin >> type; - - double payable = calculateFinalAmount(amount, type); - cout << "Final Payable Amount: " << payable << endl; - - return 0; -}