Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions tasks/task-03/HarshitRSethi/calculator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <iostream>
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;
}
30 changes: 0 additions & 30 deletions tasks/task-03/calculator.cpp

This file was deleted.