Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| def calculate_tip(total_amount, people, tip_percent): | |
| tip = total_amount * (tip_percent / 100) | |
| grand_total = total_amount + tip | |
| per_person = grand_total / people | |
| return tip, grand_total, per_person | |
| def main(): | |
| st.set_page_config(page_title="Bill Splitter", page_icon="πΈ") | |
| st.title("πΈ Bill Splitter + Tip Calculator") | |
| st.markdown("Split your bill with friends & add a fair tip.") | |
| total_amount = st.number_input("Total Bill Amount (PKR)", min_value=0.0, step=50.0, format="%.2f") | |
| people = st.number_input("Number of People", min_value=1, step=1) | |
| tip_percent = st.slider("Tip Percentage", min_value=0, max_value=50, value=10) | |
| if st.button("Calculate"): | |
| tip, grand_total, per_person = calculate_tip(total_amount, people, tip_percent) | |
| st.success(f"π° Tip: PKR {tip:.2f}") | |
| st.info(f"π§Ύ Grand Total: PKR {grand_total:.2f}") | |
| st.success(f"π₯ Each Person Pays: PKR {per_person:.2f}") | |
| if tip_percent < 5: | |
| st.caption("π§ Cold-hearted tipping π ") | |
| elif tip_percent <= 15: | |
| st.caption("π«‘ Standard tipper β you're good.") | |
| else: | |
| st.caption("π Generous boss vibes!") | |
| if __name__ == "__main__": | |
| main() | |