Ask your own question, for FREE!
Computer Science 10 Online
OpenStudy (anonymous):

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

OpenStudy (anonymous):

by the way this is for C and C++

OpenStudy (anonymous):

#include <stdio.h> #include <string.h> int main (void) {

OpenStudy (anonymous):

#include <stdio.h> #include <string.h> float getTotal (float expense[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; }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!