Stuck on this computer science assignment ________________________________ We mu
ID: 3767212 • Letter: S
Question
Stuck on this computer science assignment
________________________________
We must use this template:
#include <iostream>
#include <fstream>
using namespace std;
bool DEBUG = false;
int SIZE = 10;
int CHOICESIZE = 3;
int MAX_COMPANY_NAME_LENGTH = 20;
//the integer value returned will be the index of value_to_find in array_to_search or -1 if it is not present
int binarySearch(const string* array_to_search, string value_to_find, int array_length);
//reads from earnings.txt double values into the array argument.
void readValues(double* array_to_store_in, int array_length);
//reads from companies.txt string values into the array_to_store_in argument.
//the integer value returned will be the number of companies read from the file.
//It will be between 3 and 10 depending on the input file
//the array_to_store_spaces will be filled with " " space characters so that each member of the array corresponds with a company name to have a total length of MAX_COMPANY_NAME.
//Therefore if a company name at index 3 was "General_Motors" the value in the spaces array at index 3 would be " " or six spaces.
int readCompanies(string* array_to_store_in, string* array_to_store_spaces, int array_length);
//prints out the menu of company names and earnings.
void printMenu(const string* array_companynames, const string* array_spaces, const double* array_earnings, int array_length);
int main(){
}
____________________
Here's what's inside the .txt files
Input1.txt
Aperture_Science
Malo_Mart
Silph_Co
n
MTT_Resort
Malo_Mart
Shinra_Inc
q
_______________________
Input2.txt
aaa
Cannon_Travel
_Science_Inc
Gadd_Science_Inc
zzz
Recettear
Q
______________
Input3.txt
Not_A_Company
MTT_Resort
Shinra_Inc
Silph_Co
n
broken_name
Recettear
bad_name
Malo_Mart
another_bad
Silph_Co
Q
______________
earnings.txt
0.52
9643.21
20.45
235434.2
1753544.3
820000
232.12
25768.45
______________
companies.txt
Aperture_Science
Cannon_Travel
Gadd_Science_Inc
MTT_Resort
Malo_Mart
Recettear
Shinra_Inc
Silph_Co
__________________
Here's an example of a run of the solution:
______________________
Thanks guys!
Explanation / Answer
#include <iostream>
#include <fstream>
using namespace std;
bool DEBUG = false;
int SIZE = 10;
int CHOICESIZE = 3;
int MAX_COMPANY_NAME_LENGTH = 20;
//the integer value returned will be the index of value_to_find in array_to_search or -1 if it is not present
int binarySearch(const string* array_to_search, string value_to_find, int array_length);
//reads from earnings.txt double values into the array argument.
void readValues(double* array_to_store_in, int array_length);
//reads from companies.txt string values into the array_to_store_in argument.
//the integer value returned will be the number of companies read from the file.
//It will be between 3 and 10 depending on the input file
//the array_to_store_spaces will be filled with " " space characters so that each member of the array corresponds with a company name to have a total length of MAX_COMPANY_NAME.
//Therefore if a company name at index 3 was "General_Motors" the value in the spaces array at index 3 would be " " or six spaces.
int readCompanies(string* array_to_store_in, string* array_to_store_spaces, int array_length);
//prints out the menu of company names and earnings.
void printMenu(const string* array_companynames, const string* array_spaces, const double* array_earnings, int array_length);
int main(){
}
____________________
Here's what's inside the .txt files
Input1.txt
Aperture_Science
Malo_Mart
Silph_Co
n
MTT_Resort
Malo_Mart
Shinra_Inc
q