automated commit by check50 [check50=True]

This commit is contained in:
kukemuna 2024-02-23 21:23:33 +02:00
commit 74816db2fe
1 changed files with 24 additions and 0 deletions

24
half.c Normal file
View File

@ -0,0 +1,24 @@
// Calculate your half of a restaurant bill
// Data types, operations, type casting, return value
#include <cs50.h>
#include <stdio.h>
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;
}