develop C++ code

hi i have an assignment in C++ i wrote the code but is not working can you fix it the due is after 6 hours from now
lp_miniproject_code_.docx

lp_miniproject_.docx

Don't use plagiarized sources. Get Your Custom Essay on
develop C++ code
Just from $13/Page
Order Essay

Unformatted Attachment Preview

Compiler used: Microsoft Visual Studio 2015
Program description: This program will automatically generate
an LP model using multidimensional arrays. It will show the entire LP model, including
the objective function, constraints, and non-negativity constraints. */
#include
#include
#include
using namespace std;
ifstream input_file;
ofstream lindo_output_file;
ofstream lpsolve_output_file;
// function name: welcome_screen
// purpose: this function will introduce the user to
// the creators of the program and what the program does
// input(s): format_choice
// output(s): none
void welcome_screen(int &format_choice);
// function name: inputting_numbers
// purpose: this function will import the numbers from the text
// file to C++, storing all of the numbers in a multidimensional array.
// input(s): data_array
// output(s): none
void inputting_numbers(int format_choice,int data_array[][5]);
// function name: objective_function
// purpose: this function will generate the objective function of the LP model
// input(s): none
// output(s): data_array
void objective_function(int format_choice, int data_array[][5]);
// function name: constraints
// purpose: this function will generate the constraints
// based on the values put in the muldimensional arrays
// input(s): none
// output(s): data_array
void constraints(int format_choice,int data_array[][5]);
// function name: non_negativity_constraints
// purpose: this function will generate the non-negativity constraints
// based on the values put in the muldimensional arrays
// input(s): none
// output(s): data_array
void non_negativity_constraints(int format_choice,int data_array[][5]);
int main()
{
lindo_output_file.open(“ELTD_mp2_output.ltx”);
lpsolve_output_file.open(“ELTD_mp2_output.lp”);
int format_choice;
int data_array[6][5];
welcome_screen(format_choice);
inputting_numbers(format_choice, data_array);
objective_function(format_choice, data_array);
constraints(format_choice,data_array);
non_negativity_constraints(format_choice,data_array);
system(“pause”);
}
void welcome_screen(int &format_choice)
{
cout << "Welcome to the Automatic LP model generation program, created by " << endl; cout << "and Tachema Davis in the year 2018. This program will automatically generate " << endl; cout << "the constraints of your LP model, inputting the data from a file and outputting " << endl; cout << "the results onto the screen and another file." << endl << endl; cout << "To start the program, please choose from the following menu: " << endl; cout << "1. LINDO-formatted LP model" << endl; cout << "2. LPSolve-formatted LP model" << endl; lindo_output_file << "Welcome to the Automatic LP model generation program, created by Eduardo Lopez " << endl; lindo_output_file << "and Tachema Davis in the year 2018. This program will automatically generate " << endl; lindo_output_file << "the constraints of your LP model, inputting the data from a file and outputting " << endl; lindo_output_file << "the results onto the screen and another file." << endl << endl; lindo_output_file << "To start the program, please choose from the following menu: " << endl; lindo_output_file << "1. LINDO-formatted LP model" << endl; lindo_output_file << "2. LPSolve-formatted LP model" << endl; lpsolve_output_file << "Welcome to the Automatic LP model generation program, created by Eduardo Lopez " << endl; lpsolve_output_file << "and Tachema Davis in the year 2018. This program will automatically generate " << endl; lpsolve_output_file << "the constraints of your LP model, inputting the data from a file and outputting " << endl; lpsolve_output_file << "the results onto the screen and another file." << endl << endl; lpsolve_output_file << "To start the program, please choose from the following menu: " << endl; lpsolve_output_file << "1. LINDO-formatted LP model" << endl; lpsolve_output_file << "2. LPSolve-formatted LP model" << endl; cin >> format_choice; cout << endl; } void inputting_numbers(int format_choice,int data_array[][5]) { input_file.open("input.txt"); assert(!input_file.fail()); int j = 0; int k = 0; input_file >> data_array[j][k];
//loop to obtain the data from the input file
while (!input_file.eof())
{
k++;
input_file >> data_array[j][k];
if (k > 4)
{
j++;
k = 0;
}
}
input_file.close();
}
void objective_function(int format_choice,int data_array[][5])
{
if (format_choice == 1)
{
cout << "! Objective Function" << endl << endl; lindo_output_file << "! Objective Function" << endl << endl; cout << "MIN "; lindo_output_file << "MIN "; int subscript = 0; int j = 0; int k = 0; //loop to generate objective function for (k = 0; k < 4; k++) { subscript++; cout << data_array[j][k] << "X" << subscript; lindo_output_file << data_array[j][k] << "X" << subscript; // different decision constructs to deal with possible negative values in the file if (data_array[j][k+1] >= 0 & k != 3)
{
cout << "+ "; lindo_output_file << "+ "; } else if (data_array[j][k+1] < 0) { cout << " "; lindo_output_file << " "; } else if (k = 3) { cout << "" << endl << endl << endl; lindo_output_file << "" << endl << endl << endl; } } } if (format_choice == 2) { cout << " /* Objective Function */" << endl << endl; lpsolve_output_file << " /* Objective Function */" << endl << endl; cout << "MIN "; lpsolve_output_file << "MIN "; int subscript = 0; int j = 0; int k = 0; for (k = 0; k < 4; k++) { subscript++; cout << data_array[j][k] << "X" << subscript; lpsolve_output_file << data_array[j][k] << "X" << subscript; if (data_array[j][k+1] >= 0 & k != 3)
{
cout << "+ "; lpsolve_output_file << "+ "; } else if (data_array[j][k+1] < 0) { cout << " "; lpsolve_output_file << " "; } else if (k = 3) { cout << ";" << endl << endl << endl << endl; lpsolve_output_file << ";" << endl << endl << endl << endl; } } } } void constraints(int format_choice,int data_array[][5]) { if (format_choice == 1) { cout << "!Constraints" << endl << endl; lindo_output_file << "!Constraints" << endl << endl; cout << "SUBJECT TO" << endl << endl; lindo_output_file << "SUBJECT TO" << endl << endl; int j = 1; int k = 0; int subscript = 0; // loop to generate constraints for (j = 1; j < 5; j++) { for (k = 0; k < 5; k++) { subscript++; cout << data_array[j][k] << "X" << subscript; lindo_output_file << data_array[j][k] << "X" << subscript; // different decision constructs to deal with possible negative values in the file if (subscript < 4 & data_array[j][k+1] >= 0)
{
cout << " + "; lindo_output_file << " + "; } else if (subscript < 4 & data_array[j][k+1] < 0) { cout << " "; lindo_output_file << " "; } else { cout << " >= “;
lindo_output_file << " >= “;
k++;
cout << data_array[j][k] << endl << endl << endl; lindo_output_file << data_array[j][k] << endl << endl << endl; subscript = 0; } } } } if (format_choice == 2) { cout << "/*Constraints*/" << endl << endl; lpsolve_output_file << "/*Constraints*/" << endl << endl; cout << "/*SUBJECT TO*/" << endl << endl; lpsolve_output_file << "/*SUBJECT TO*/" << endl << endl; int j = 1; int k = 0; int subscript = 0; int constraint_number = 1; for (j = 1; j < 5; j++) { cout << "constraint" << constraint_number << ": "; lpsolve_output_file<< "constraint" << constraint_number << ": "; constraint_number++; for (k = 0; k < 5; k++) { subscript++; cout << data_array[j][k] << "X" << subscript; lpsolve_output_file << data_array[j][k] << "X" << subscript; if (subscript < 4 & data_array[j][k+1] >= 0)
{
cout << " + "; lpsolve_output_file << " + "; } else if (subscript < 4 & data_array[j][k+1] < 0) { cout << " "; lpsolve_output_file << " "; } else { cout << " >= “;
lpsolve_output_file << " >= “;
k++;
cout << data_array[j][k] << ";" << endl << endl << endl; lpsolve_output_file << data_array[j][k] << ";" << endl << endl << endl; subscript = 0; } } } } } void non_negativity_constraints(int format_choice,int data_array[][5]) { if (format_choice == 1) { cout << "! Non-negativity Constraints" << endl << endl; lindo_output_file << "! Non-negativity Constraints" << endl << endl; int subscript = 0; int j = 5; int k = 0; for (k = 0; k < 4; k++) { subscript++; cout << data_array[j][k] << "X" << subscript << " >= 0″ << endl; lindo_output_file << data_array[j][k] << "X" << subscript << " >= 0″ << endl; } cout << endl << endl << "! This is the end of the LINDO-formatted LP model. " << endl << endl; lindo_output_file << endl << endl << "! This is the end of the LINDO-formatted LP model. " << endl << endl; } if (format_choice == 2) { cout << " /*Non-negativity Constraints*/" << endl << endl; lpsolve_output_file << " /*Non-negativity Constraints*/" << endl << endl; int subscript = 0; int j = 5; int k = 0; for (k = 0; k < 4; k++) { subscript++; cout << data_array[j][k] << "X" << subscript << " >= 0;” << endl; lpsolve_output_file << data_array[j][k] << "X" << subscript << " >= 0;” << endl; } cout << endl << endl << "! This is the end of the LPSolve-formatted LP model. " << endl << endl; lpsolve_output_file << endl << endl << "! This is the end of the LPSolveformatted LP model. " << endl << endl; } lindo_output_file.close(); lpsolve_output_file.close(); } NOTE: No late assignments will be accepted for any reasons!) The objective for this MiniProject is to develop C++ code [i.e., based on our previous lectures] to accomplish (finalize) the task of automatic LP model generation. Each student pair team (based on the original MiniProject assignment from February) must use the same LP model (again, from the MiniProject assignment) to generate a ‘LINDOformatted’ LP model and a ‘LPSolve-formatted’ LP model automatically. Your program should start with an opening screen which shows the creators’ names of the code, the year it was made, and an explanation of what the program will do. After this, the program should show the user a menu to allow them to choose which format to generate (LINDO or LPSolve). As always, your code MUST be in modular programming format. This means that the main ( ) function must only do function calls and nothing else. If the top-down programming format is used within only a single main ( ) function, your team will automatically receive no extra credit points for this Bonus MiniProject assignment. You may use more than one array to accomplish the data extraction for the objective function and the constraints, or you can combine this data into one array if you have the technical expertise in separating the data to generate the model. Keep in mind that the data must go to both the screen and an output file simultaneously (see examples from IEGR 304 NOTES or cplusplus.com). As in the prior MiniProject, this Bonus project must handle negative values in the constraints. For example, if the data for a constraint is {2, 3, 4, -5, -7, 14}, then its corresponding constraint in LINDO would be the following: 2X1 - 3X2 + 4X3 - 5X4 - 7X5 <= 14 If this is coded improperly (i.e., 2X1 + -3X2 + ...), it will never work in LINDO. Thus, your project would lose a bonus point. This output file should have the proper LINDO ‘.ltx’ or LPSolve ‘.lp’ extensions...depending on the user’s choice. When naming the file, use both team members’ initials in the output file name (i.e., RPGC_mp1_output.ltx or RPGC_mp1_output.lp if I were in a team with Dr. Guangming Chen). Also, use plenty of comments throughout the code...especially for each function as you have learned in the earlier IEGR 304 course, and be sure to make ‘LINDO-style’ or ‘LPSolvestyle’ comments for the LP model sections of ‘Objective Function’, ‘Constraints’, and ‘Non-negativity Constraints’ as shown in the examples which are shown at the end of these instructions. The actual objective function, general constraints, and non-negativity constraints must be extracted from a numbers-only data input file (i.e., a .txt file), and the C++ code must generate the LP models while utilizing multi-dimensional data arrays, repetition (loops), and decision constructs (if...else statements). When the assignment is completed, that plagiarism has taken place, this assignment and all bonus points gained will be forfeited. Sample LINDO-formatted and lpSolve-formatted source files are on the next pages for your reference. submit the .txt input data file, the .cpp source file and both output types LINDO (.ltx) and lpSolve (.lp) model files via your Bb account by the due date and time. If it is determined GOOD LUCK! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Don’t be late! Please note that once the due date and time has passed, you will not be able to submit the Bonus MiniProject because the submission link will disappear from the Bb screen! It will not be reactivated for any reason/excuse, so avoid this by turning it in early!! Yes...you can ALWAYS turn it in early if you don’t wait until the last minute!! LINDO Output File Example: ! Objective Function MAX 10X1 + 20X2 + 30X3 ! Constraints SUBJECT TO -3X1 + 5X2 - 7X3 <= 25 2.5X1 + 0X2 + 4X3 <= 35 ! Non-negativity Constraints X1 >= 0 X2 >= 0 X3 >= 0
! This is the end of the LINDO-formatted LP model.

Purchase answer to see full
attachment

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

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

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.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

Order your essay today and save 15% with the discount code DISCOUNT15