Question: *************REPOSTING AS I AM STILL HAVING PROBLEMS************ (I AM ALWAYS GOOD AT RATING MY QUESTIONS) HELLO! PLEASE HELP WITH DEBUGGING MY SOLUTION. I AM RUNNING

*************REPOSTING AS I AM STILL HAVING PROBLEMS************

(I AM ALWAYS GOOD AT RATING MY QUESTIONS)

HELLO!

PLEASE HELP WITH DEBUGGING MY SOLUTION. I AM RUNNING THIS THROUGH DEV C++ COMPILER SO SOLUTION HAS TO BE COMPATIBLE WITH THIS.

I HAVE POSTED THIS QUESTION THREE OTHER TIMES ALREADY, BUT SOLUTIONS HAVE NOT BEEN COMPLETELY HELPFUL. BELOW I AM POSTING A DIFFERENT VERSION OF MY SOLUTION AS I THINK MAYBE IT WILL HELP?

IN THIS CURRENT VERSION, NO ERRORS IN DEV C++ ARE DETECTED BUT THE CALCULATIONS ARE NOT WORKING COMPLETELY. OPTIONS SUM, AVERAGE, DEPOSIT, LOWEST ARE NOT RENDERING ANY RESULTS. I AM JUST GETTING 0. BUT WHEN I RUN THIS THROUGH AN ONLINE C COMPILER I AM GETTING RESULTS FINE. AGAIN THIS NEEDS TO RUN IN DEV C++ WITHOUT THESE ERRORS.

I APPRECIATE ALL HELP.

THIS IS DUE SOON.

*************************************

ASSIGNMENT BACKGROUND:

MUST BE WRITTEN IN C ONLY.

DO NOT USE GLOBAL VARIABLES

WRITE A MENU DRIVEN PROGRAM THAT COMPLETES THE ACTIONS LISTED BELOW WITH ITS ASSOCIATED INPUT.

UTILIZE SWITCH

UTILIZE 1D ARRAY

INCLUDE PREVENTATIVE CODING (IF THE USER MAKES WRONG INPUT, SYSTEM NOTIFES THEM AND RETURNS THEM TO MAIN MENU)

USE CALL BY REFERENCE / VALUE WHEREVER APPROPRIATE

************************************

MY SOLUTION:

#include #include //function declarations

void sortedValues(int deposits[], int length, int count); void lowestValue(int deposits[], int length, int count) ; int sumValues(int deposits[], int length);

//main function int main(){ char userChoice; int temp=1; int count=0; int length=100000; int deposits[100000]; int i; for (i=0;i

printf("***MAIN MENU*** "); printf("Press [G]et new deposit "); printf("Press [S]um of all deposits "); printf("Press [D]eposits will be displayed from highest to lowest deposit "); printf("Press [A]verage of all deposits "); printf("Press [L]owest deposit will be displayed "); printf("Press [Q]uit the program ");

printf("Enter your choice: "); scanf(" %c", &userChoice);

switch (userChoice) { case 'G': { printf("Enter new deposit: "); scanf("%d", &newDeposit); deposits[i]=newDeposit; i++;count++; printf("New deposit made "); break; } case 'S': { printf("Sum of all deposits: "); sum = sumValues(deposits, length); printf("%d", sum); break; } case 'D': { printf("Deposits displayed from highest to lowest deposit: "); sortedValues(deposits, length, count);

break; }

case 'A': { printf("Average of all the deposits: "); avg = sumValues(deposits, length); avg=avg/count; printf("%d", avg); break; } case 'L': { printf("Lowest deposit is displayed below: "); lowestValue(deposits, length, count) ; break; } case 'Q': { printf("Exiting the program... "); return 0; } default: printf("Invalid input. Please make a valid input. "); }

printf(" Press 1 to back to Main Menu: "); scanf("%d", &temp); } return 0; }

//function to get descending order of deposits void sortedValues(int deposits[], int length, int count) { int temp=0; int i; int j; for (i = 0; i < count; i++) { for (j = i+1; j < count; j++) { if(deposits[i] < deposits[j]) { temp = deposits[i]; deposits[i] = deposits[j]; deposits[j] = temp; } } }

// printing the sorted deposits in descending order for ( i = 0; i < count; i++) { printf("%d ", deposits[i]); } }

//function to get lowest deposit value void lowestValue(int deposits[], int length, int count) { int temp=0; int i; int j; for ( i = 0; i < count; i++) { for ( j = i+1; j < count; j++) { if(deposits[i] < deposits[j]) { temp = deposits[i]; deposits[i] = deposits[j]; deposits[j] = temp; } } } printf("%d", deposits[count-1]); }

//function to get sum of all deposits int sumValues(int deposits[], int length){ int sum=0; int i; for (i=0;i

return sum; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!