File size: 1,293 Bytes
7061a38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()