Question: C Programming Help! Program Specifications: You are to DESIGN and WRITE a menu driven program as shown by the sample menu below. Should the user
C Programming Help!
Program Specifications:
You are to DESIGN and WRITE a menu driven program as shown by the
sample menu below. Should the user select [G] the program will ask the
user to enter a single deposit into the bank account. The rest of the menu
options are self-explanatory.
*** BANKING MAIN MENU ***
[G]et a new deposit
[S]um of all deposits
[D]eposits will be displayed from highest to lowest deposit
[A]verage of all deposits
[L]owest deposit will be displayed
[Q]uit the program
YOU CANNOT:
Use global variables, in this or any program ever.
Use goto statement(s) , in this or any program ever.
This is what I have so far:
#include int main() { int n = 0; int deposit[100]; char input; { printf("*** BANKING MAIN MENU *** [G]et a new deposit [S]um of all deposits [D]eposits will be displayed from highest to lowest deposit [A]verage of all deposits [L]owest deposit will be displayed [Q]uit the program "); printf("Enter : "); scanf_s("%c", &input); if (input == 'Q') { return 0; } else if (input == 'G') { printf("Please input Deposite Amount : "); scanf_s("%d", &deposit[n]); n++; } else if (input == 'S') { int sum = 0; for (int i = 0; i < n; i++) { sum += deposit[i]; } printf("Total Sum : %d", sum); } else if (input == 'D') { for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1 - i; j++) { if (deposit[j] < deposit[j + 1]) { int temp = deposit[j + 1]; deposit[j + 1] = deposit[j]; deposit[j] = temp; } } } for (int i = 0; i < n; i++) { printf("%d ", deposit[i]); } } else if (input == 'A') { int sum = 0; for (int i = 0; i < n; i++) { sum += deposit[i]; } double average = (double)sum / (double)n; printf("Average deposite is : %f ", average); } else if (input == 'L') { for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1 - i; j++) { if (deposit[j] > deposit[j + 1]) { int temp = deposit[j + 1]; deposit[j + 1] = deposit[j]; deposit[j] = temp; } } } printf("lowest Deposite is : %d", deposit[0]); } printf(" "); fflush(stdin); }
return 0; }
I need help with the deposit memory, the program keeps shutting down after I plug in the first deposit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
