Answered Essay: Competent 200 (20%)-400 (40%) 5 Different algorithms are Sortin 0 (0%)-100 (10%) 100 (10%)-200 (20%) 1 or two algorithms a

1. You will pick 10 stocks from this list: https://finance.yahoo.com/quote/%5EDJI/components?p=%5EDJI

2. create a program that takes the stock’s symbol, company name, last price, change, and volume as input from a file. How the file is formatted and inputed is up to you and you can put underscores between words in the companies name instead of using spaces. Store these values in either

-a 2 dimensional array or vector of strings (may require converting strings to floats using:stof(stringVariable,nullptr); )

-5 individual arrays or vectors of their correct types

-You may create a class or struct with the proper members for the data for each company, then create an array or vector of the class or struct type.

3. After input, it will display the information on the terminal. Users will have the option of sorting the information by any of the five categories of information. Depending on which category the data is being sorted by, you will sort using a different sorting algorithm.

4. The user will also be able to change the stock price.. When this option is selected,

-the user should input the stock symbol.

-The array will be searched using a binary search

-If the symbol is found, all the information for that company will be displayed, else an error message will be displayed.

-The user will be able to enter a new price for the stock.

-This value will be updated in the array.

5. When the user exits, all data will be written back to the file.

The language for this program should be in C++

Competent 200 (20%)-400 (40%) 5 Different algorithms are Sortin 0 (0%)-100 (10%) 100 (10%)-200 (20%) 1 or two algorithms are used and coded properly and/or the information in the arrays are jumbled by and/or a couple algorithmsused for the five different are not coded properly and/or the arrays are not categories to be sorted They are coded properly and the two dimensional arrays are sorted properly 0 (0%)-50 (596) 50 (5%)-100 (1096) 100 (10%)-200 (20%) Binary search not used, or completely off, or search item not returned, even if the search item is in array Binary search is used, but implementation is off a bit and/or no error message is displayed if data not Binary search is used and implemented properly Error message is displayed if data not 75 (7.5%)-150 (1596) 0 (0%)-25 (2.5%) Data is neither loaded nor outputted properly 25 (2.5%)-75 (7.5%) Data is either not loaded properly or not outputted to file properly File Input/Output Data is loaded into arrays properly and outputted to file properly 50 (5%)-100 (1096) All functions and code blocks have sufficient commenting. Any lines of code that are unclear are 0 (0%)-25 (2.5%) Little or no commenting. 25 (2.5%)-50 (596) Some functions or code blocks are not commented or several lines of unclear code are not commented 9 User Interface 0 (0%)-50 (596) 50 (596)-100 (1096) 100 (10%)-150 (15%) Formatting is messy and i Formatting is not very nice Output to console is is unclear how to use the formatted nicely Functionality is explained on screen and using the program is simple and/or how to use the program is unclear

Competent 200 (20%)-400 (40%) 5 Different algorithms are Sortin 0 (0%)-100 (10%) 100 (10%)-200 (20%) 1 or two algorithms are used and coded properly and/or the information in the arrays are jumbled by and/or a couple algorithmsused for the five different are not coded properly and/or the arrays are not categories to be sorted They are coded properly and the two dimensional arrays are sorted properly 0 (0%)-50 (596) 50 (5%)-100 (1096) 100 (10%)-200 (20%) Binary search not used, or completely off, or search item not returned, even if the search item is in array Binary search is used, but implementation is off a bit and/or no error message is displayed if data not Binary search is used and implemented properly Error message is displayed if data not 75 (7.5%)-150 (1596) 0 (0%)-25 (2.5%) Data is neither loaded nor outputted properly 25 (2.5%)-75 (7.5%) Data is either not loaded properly or not outputted to file properly File Input/Output Data is loaded into arrays properly and outputted to file properly 50 (5%)-100 (1096) All functions and code blocks have sufficient commenting. Any lines of code that are unclear are 0 (0%)-25 (2.5%) Little or no commenting. 25 (2.5%)-50 (596) Some functions or code blocks are not commented or several lines of unclear code are not commented 9 User Interface 0 (0%)-50 (596) 50 (596)-100 (1096) 100 (10%)-150 (15%) Formatting is messy and i Formatting is not very nice Output to console is is unclear how to use the formatted nicely Functionality is explained on screen and using the program is simple and/or how to use the program is unclear

Expert Answer

 

#include <iostream.h>

#include <string.h>

#include <fstream.h>

#include <iomanip.h>

#include<math.h>

#include<stdlib.h>

#include<conio.h>

struct Stock

{

int no;

char symbol[50];

char company_name[50];

float LastPrice;

float Change;

float PercentageChange;

long Volume;

};

const int SIZE = 10;

const int INFO = 6;

fstream file;

// Function prototypes

void openInputFile(ifstream &, char str[]);

void getTotal(Stock[]);

void sort(Stock[]);

int main()

{

clrscr();

// Variables

Stock arr[SIZE];

 

ifstream inFile;

char inFileName[50] = “stdout1.txt”;

// Call function to read data in file

openInputFile(inFile, inFileName);

// Read data into an array of structs

for(int count = 0; count < SIZE; count++)

{

inFile >> arr[count].symbol >> arr[count].company_name >> arr[count].LastPrice >> arr[count].Change >> arr[count].PercentageChange >> arr[count].Volume;

}

// Close input file

inFile.close();

// Sort data

sort(arr);

system(“PAUSE”);

//writing data to the file

file.open (“test.txt”, ios::out);

if(file)

{

file.write((char*)arr,sizeof(Stock));

}

else

cout <<“Error opening the file!n”;

file.close();

getch();

return 0;

}

//opening file method

void openInputFile(ifstream &inFile,char inFileName[])

{

//Open the file

inFile.open(inFileName);

//Input validation

if (!inFile)

{

cout << “Error to open file.” << endl;

cout << endl;

return;

}

}

/**

Sorting method based on LastPrice

*/

void sort(Stock arr[])

{

Stock temp;

for (int i = 0; i < (SIZE – 1); i++)

{

for (int j = i + 1; j < SIZE; j++)

{

if (arr[i].LastPrice > arr[j].LastPrice)

{

temp = arr[i];

arr[i] = arr[j];

arr[j] = temp;

}

}

}

}

//**************************************************************

// Definition of function sortArray. *

// This function performs an ascending order selection sort on *

// array. size is the number of elements in the array. *

//**************************************************************

void sortArray(string names[], int size)

{

int startScan, minIndex;

string minValue;

for (startScan = 0; startScan < (size – 1); startScan++)

{

minIndex = startScan;

minValue = names[startScan];

for(int index = startScan + 1; index < size; index++)

{

if (names[index] < minValue)

{

minValue = names[index];

minIndex = index;

}

}

names[minIndex] = names[startScan];

names[startScan] = minValue;

}

}

//***************************************************************

// The binarySearch function performs a binary search on an *

*

//***************************************************************

int binarySearch(string names[], int size, string value)

{

int first = 0, // First array element

last = size – 1, // Last array element

middle, // Mid point of search

position = -1; // Position of search value

bool found = false; // Flag

while (!found && first <= last)

{

middle = (first + last) / 2; // Calculate mid point

if (names[middle] == value) // If value is found at mid

{

found = true;

position = middle;

}

else if (names[middle] > value) // If value is in lower half

last = middle – 1;

else

first = middle + 1; // If value is in upper half

}

return position;

}

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.