InstructionsUsign the IDE (i.e. CLion, Visual Studio 2019, Code Blokcs, Replit, etc) of your choice, write a program following the instructions described below and upload your source file (.cpp).You...










Instructions








Usign the IDE (i.e. CLion, Visual Studio 2019, Code Blokcs, Replit, etc) of your choice, write a program following the instructions described below and upload your source file (.cpp).




You must submit your work by





Sunday, December 11 @ 8:00pm.















Program Description








Write a program that reads floating-point numbers from afileinto avector. After the values are read,itcomputes the median valueand determines if the median value is in the file. The program should write to a file the numbers in ascending order, the median value, and whether the median value is in the file.




You will need to arrange the numbers in ascending order. To do so, you may either useselection sortorinsertion sortto sort the vector. To determine if the median value is in the file, you are required to use abinary search.




To compute the median you must firtst arrange the numbers in ascending order and then find the middle number. When the amount of numbers isoddthere will only be1 middle number.





For example, if the numbers are {1,5,7,9,11,13,15,17,19} then 11 is the median.




However, if the amount of numbers iseven, then there will be2 middle numbers. In this case you must take theaverageof the2 middle numbersby adding them and then dividing by 2.




For example, if the numbers are {2,4,6,8,10,12,14,16,18,20,22,24} then 13 is the median (i.e. (12+14) / 2 = 13).










Function Requirements








Your program


MUST


implement the following functions:







  • A function whichreads the numbersfrom the file into the vector. Theifstreamobject and thevectormust be


    passed by reference


    . The file should be closed after all the numbers are read.



  • A function whichsorts the vectorinascending orderusingselection sortorinsertion sort. Thevectormust be


    passed by reference


    .



  • A function whichcomputesandreturnsthemedian value.Thesorted


    vectormust be


    passed by reference


    ,but the function shouldNOTbe allowed tomodifyit.



  • A function which performs abinary searchon thesorted


    vectorto determine if the median valueis in the file. If it is, it should return the index, otherwise it should return -1.Thesorted


    vectormust be


    passed by reference


    ,but the function shouldNOTbe allowed tomodifyit. Themedian valueshould be


    passed by value


    .



  • A function whichwrites to a filethenumbers in ascending order, themedian value, andwhether the median value is in the file. Thesorted


    vectormust be


    passed by reference


    ,but the function shouldNOTbe allowed tomodifyit. The other 2 arguments should be


    passed by value


    .












Input/Output Requirements








The program mustprompt the userfor thenamesof the input and output files. If either file can't be opened, an error message should be displayed and the program should exit.







==> NOTE:Each Floating-Point number in the file is stored in aseparate line.







==> NOTE :Usemedian.txtas the input file in order to test your program. Your program will be graded with a different input file.










Other Requirements











  • The program is required to useLoopsfor processing the vectors.






  • Global variablesthat areNOTconstants shouldNOTbe used.


    Using them will result in a penalty of 60 points!








  • Insert acommentwithyour nameat thetopof your program.



  • Usedescriptive variable namesandformatthecodeso that it'seasy to read.












How to Submit








1) Save your program and rename your source file (.cpp) using your first and last name. Example: John Doe.cpp. Your source file is located in your project's folder.




2) Upload your source file by





Sunday, December 11 @ 8:00pm.





You may submit2 times, however only the last submission will be graded. (


Note:





Late submissions will NOT be accepted.)










Note:Programs thatdon't compilewill receiveat most50 points.



Dec 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here