Question
Question: From the name of the C++ file must be search.cpp Wre a program that will read data from a file. The program will allow
Question:
From the name of the C++ file must be search.cpp Wre a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will be searched for in the array using binary search. Make sure to include the following A sort function must be called before the binary search. Implement the selection sort function that uses findMin and swap functions as discussed in lecture Include a function called by main to implement the binary search The ordered array produced by the sort function should be passed to the search routine which returns the location in the sorted array of the sought value, or -1 if the value s not in the array Add a value returning function that computes the median of your data set. (f.e. main function will display the median) -Use showArray function to show elements of the array before sorting and after sorting as required in the program output. The function should display the array values nicely formattedn rows Your program should output The total number of elements read from the file (valid items in the array) The array as read from the file The sorted array The integer being searched for and the location of that integer in the sorted array (or an-- - appropriate message if it is not in the array) -The median of the data set Assume that the maximum number of values in the input file wll not exceed 50. Sample input file: data.dat
Please use C++ for this program.
Please read the problem and follow the instruction in main.cpp for this program.
Problem: - Design an abstract class called Shape: - Private variables double x and y, this is x and y position in postscript file - Constructor shape (x, y) that assign x and y values - function area take no parameters return double const equal zero, pure virtual function - function draw take ostream file return void and equal zero, pure virtual function - make deconstruct ~Shape - Hint: you need to use virtual - Design class Circle that inherit class shape functions - private variable x, y, radius - Make the following functions: - Circle constructor that take x, y, radius, Note that x and y are assigned to Shape(x,y) - for example constructor_name(double x, double y) : Shape(x,y) - draw that take ostream file to write postscript instruction the function return void - area take no parameters and return double area of the circle - ~Circle deconstruction - Design class Rect that inherit class shape with same functions as class Circle - private variables are x, y, weight, height - Design class FilledRect that inherit class shape with same functions as class Circle - private variables are x, y, weight, height - Hint for Circle, Rect, and FilledRect: you will need to use override keyword - e.g.: data_return_type function_name(inputs) override {} - Design class Drawing that take all shapes created and save it in vectors. Then use draw function for each Shape to write test.ps file with postscripts instructions - it has private variables of type: ofstream and vector
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started