This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Bill Division #70
Comments
I want to solve it using c++ |
samarjeetvashistha
added a commit
to samarjeetvashistha/hacktoberfest
that referenced
this issue
Oct 21, 2022
I contributed in cognizance-amrita#70
Merged
I would also like to contribute and solve this issue in python & java . Can you assign me this one @ndrohith09 |
i would like to contribute and solve this issue in java . can you assign me @ndrohith09 |
ndrohith09
added a commit
that referenced
this issue
Oct 24, 2022
Issue #70 : Resolve Bill divison issue in java & python
Simple-Saviour
added a commit
to Simple-Saviour/hacktoberfest
that referenced
this issue
Oct 27, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Two friends Anna and Brian, are deciding how to split the bill at a dinner. Each will only pay for the items they consume. Brian gets the check and calculates Anna's portion. You must determine if his calculation is correct.
For example, assume the bill has the following prices:
bill = [2,4,6]
. Anna declines to eat itemk=bill[2]
which costs6
. If Brian calculates the bill correctly, Anna will pay(2+4)/2=3
. If he includes the cost ofbill[2]
, he will calculate(2+4+6)/2
. In the second case, he should refund3
to Anna.Function Description
Complete the bonAppetit function in the editor below. It should print Bon Appetit if the bill is fairly split. Otherwise, it should print the integer amount of money that Brian owes Anna.
bonAppetit has the following parameter(s):
Input Format
The first line contains two space-separated integers
n
andk
, the number of items ordered and the0
-based index of the item that Anna did not eat.The second line contains
n
space-separated integersbill[i]
where0 <= i < n
.The third line contains an integer,
b
, the amount of money that Brian charged Anna for her share of the bill.Constraints
Output Format
If Brian did not overcharge Anna, print Bon Appetit on a new line; otherwise, print the difference (i.e.,
b charged - b actual
) that Brian must refund to Anna. This will always be an integer.Sample Input 0
Sample Output 0
Explanation 0
Anna didn't eat item
bill[1] = 10
, but she shared the rest of the items with Brian. The total cost of the shared items is3+2+9=14
and, split in half, the cost per person isb actual = 7
. Brian charged herb charged = 12
for her portion of the bill. We print the amount Anna was overcharged,b charged - b actual = 12 - 7 = 5
, on a new line.Sample Input 1
Sample Output 1
Explanation 1
Anna didn't eat item
bill[1] = 10
, but she shared the rest of the items with Brian. The total cost of the shared items is3+2+9=14
and, split in half, the cost per person isb actual =7
. Becauseb actual = b charged =7
, we printBon Appetit
on a new line.The text was updated successfully, but these errors were encountered: