create a program that accepts input of the following expenses:
food, gas, entertainment, medical, personal, misc
store this in an array
and ouput each item when complete with total expenses
use the following: if/else, string (strcmp), int arrays, error handling
i am not sure as how to start this program. please point me in the right direction
1 2 3 4 5 6 7 8
#include <stdio.h>
#include <string.h>
#define SIZE 6
int main (void)
{
char *Items[] = {"\nFood", "\nGas", "\nEntertainment", "\nMedical", "\nMisc" };
float expenses[] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00};
char askthem[] = {"Please enter the appropriate values for each item"};
char tellthem[] = {"here is what you put"};
char *erorfound = {"You have entered a value that is inappropriate"};
char *totalexpenses = {"Total Expenses: "};
float total;
printf("%s", askthem);
for (int i = 0; i < 6; ++i)
{
printf("%s : ", Items[i]);
scanf("%f", &expenses[i]);
}
printf("%s", tellthem);
for (int p = 0; p < 6; ++p)
printf("%s : %.2f", Items[p], expenses[p]);
printf("\n%s%.2f\n", totalexpenses, total = getTotal(expenses));
}
float getTotal (float Expense[6])
{
float total = 0.00;
for (int i = 0; i < 6; ++i);
total = total + Expense[i];
return total;
}
this is what i got but im still having trouble with the error handling