From 74816db2fef832a78d525429a2c2b1f3ae68bc22 Mon Sep 17 00:00:00 2001 From: kukemuna Date: Fri, 23 Feb 2024 21:23:33 +0200 Subject: [PATCH] automated commit by check50 [check50=True] --- half.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 half.c diff --git a/half.c b/half.c new file mode 100644 index 0000000..02dc105 --- /dev/null +++ b/half.c @@ -0,0 +1,24 @@ +// Calculate your half of a restaurant bill +// Data types, operations, type casting, return value + +#include +#include + +float half(float bill, float tax, int tip); + +int main(void) +{ + float bill_amount = get_float("Bill before tax and tip: "); + float tax_percent = get_float("Sale Tax Percent: "); + int tip_percent = get_int("Tip percent: "); + + printf("You will owe $%.2f each!\n", half(bill_amount, tax_percent, tip_percent)); +} + +// TODO: Complete the function +float half(float bill, float tax, int tip) +{ + float with_tax = (bill + (bill * (tax / 100))); + float half = (with_tax + (with_tax * ( (float) tip / 100))) / 2; + return half; +}