Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C programming assignment, Sorting And Searching Assignment 1- The program specifications. YOU MUST NOT Use global variables YOU MUST NOT Use the word goto YOU

C programming assignment, Sorting And Searching Assignment

1- The program specifications.

YOU MUST NOT Use global variables

YOU MUST NOT Use the word goto

YOU MUST NOT Use the break command outside a case statement

DO NOT ignore comments

The sort and search Assignment

Outcome:

Student will demonstrate the ability to create and populate an array

Student will demonstrate the ability to pass an array to and from a function

Student will demonstrate the ability to sort and search an array

Student will demonstrate the ability to control the arrays size and effective size

Student will demonstrate the ability to use an array of values in math formulas

Program Specifications:

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

*** MAIN MENU *******

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

A. Enter GPA

B. Display Average of all GPA's

C. Display the Highest GPA

D. Display the Lowest GPA

E. Display the adjusted average

F. See if a certain GPA was entered

G. Display The contents of the Array

Q. Quit

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

Enter your selection:

You are to write a WELL written C program that uses the menu above. All your code will be written using functions. Main will only have a menu system and a switch. Main will call all other functions. The program needs to allow for about 1000 or so GPAs or just some number, you pick, it should work with any reasonable size.

Enter GPA:

If this is selected, the user will then enter a signal value for his or her GPA (example 3.55). Remember you cannot exceed the SIZE of the array. If a GPA below 2.0 is entered: Display the following message: You need to study harder. If GPA is above 3.5 Display the following message: Nice work.

Display Average of all GPAs

If this is selected, the program will display the average of the values within the array. If now values have been entered, then the program will not display the average, instead it will message the user to enter values first.

Display Highest GPA

If this is selected, you should call a bubble sort routine, sort the array and display the value located at either array[0] or array[SIZE -1] depending on if you sorted it in ascending or descending order. Finally, if no values have been entered, the program will notify the user to enter values first.

Display Lowest GPA

If this is selected, you should call a bubble sort routine, sort the array and display the value located at either array[0] or array[SIZE -1] depending on if you sorted it in ascending or descending order. Finally, if no values have been entered, the program will notify the user to enter values first.

Display the adjusted average

If this is selected, the program will show the average of all the values in the array except for the lowest GPA value. In other words, it drops the lowest value and averages the rest. Keep in mind, that you cannot drop the lowest should you only have one value. Finally, if no values have been entered, the program will notify the user to enter values first.

See if a certain GPA was entered

The program will ask the user to enter any GPA value. Then the program will search the array for the first occurrence of that value. If the value is not found, the program will inform the user that the GPA was never entered. If the value was found, then the program would say that the value was found at the xx location in the array. For example, The GPA 3.55 the fifth value of the array. Finally, if no values have been entered, the program will notify the user to enter values first.

Display the Contents of the Array

If this is selected the array will be sorted in ascending order and the all values will be echoed to the screen.

Q. Quit

You can guess what happens here.

Submission Requirements:

You must attach your *.c source code and your design tool to the assignment thread.

Make sure you have a comment header with your name and the names of anyone else who joined you (maximum 3 people).

2- Here is: A structure chart for the program.

image text in transcribed

3-Here is: A template for you to use for this program. Copy and paste into a project.

/////////////////////////////////////////////////// // Written by..: your name goes here // // Date Written: // // Purpose.....: The sort and search assignment // /////////////////////////////////////////////////// #define _CRT_SECURE_NO_WARNINGS #define PAUSE system("pause") #define FLUSH myFlush() #define SIZE 500 #define CLS system("cls") #include #include #include // for strlen() gets the length of a string #include // for the toupper() function #include // so I can play with colors // ProtoType Functions Here void displayMessage(char m[]); char getChoice(); void displayMenu(); void myFlush(); main(){ char choice; float grades[SIZE] = {2.3, 4.3, 1.2, 4.0, 2.16, 3.33, 3.88, .9}; // I placed sample data in the array, can be removed int count = 8; // this should be zero, but I entered 8 test values above...remove both do{ choice = getChoice(); switch(choice){ case 'A': // enter a single GPA PAUSE; break; case 'B': // Display the average of all GPAs PAUSE; break; case 'C': // Display the highest GPA PAUSE; break; case 'D': // Display the lowest GPA PAUSE; break; case 'E': // Display the adjusted average break; case 'F': // Search for a certian CPA break; case 'G': // Display The Values in the Array in ascending order break; case 'Q': // Quit the program CLS; displayMessage("Thanks for using my pretty cool GPA grade program."); PAUSE; break; default: displayMessage("Invalid selection, pick again"); PAUSE; break; } // end of switch }while(choice != 'Q'); }// end of main //////////////////////////////////////////////////////////////////////////////////////////////////////// void displayMenu(){ CLS; system("COLOR E0"); printf("****************************************** "); printf("*** M A I N M E N U *** "); printf("****************************************** "); printf("A. Enter GPA "); printf("B. Display Average of all GPA's "); printf("C. Display the Highest GPA "); printf("D. Display the Lowest GPA "); printf("E. Display the adjusted average "); printf("F. See if a certian GPA was entered "); printf("G. Display The Contents of the Array "); printf("Q. Quit "); printf("****************************************** "); printf(" Enter your selection: "); }// end function displayMenu void displayMessage(char m[]){ int length = strlen(m); int i; system("COLOR 96"); // yellow on blue for(i = 0; i   MAIN OR START B. Display Avg All GPAs C. Display Highest D. Display Lowest E. Display Adj Avg F. Search G. Display contents of array Q. Quit progranm A. Enter GPA for GPA Make sure that at least one GPA has been ordered Sort from high to low and display value at array[0] Make sure that at least one GPA has been ordered Ask user for a GPA for the search. Search for the value Make sure that at least one GPA has been ordered Loop through the entire array and display all values Test for max size of array Prompt user Store next Make sure that at least one GPA has beer ordered Add up GPAs and divide by effective size Make sure at least one value has been entered Sort from low to high and display value at array[0] sort from low to Say good bye and exit Ig Save value at array[0] Add up the remaining values Divide by effective Size minus one

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago