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()