Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program works correctly but for some reason I am receiving a warning for every variable in the class. There is an example below showing

The program works correctly but for some reason I am receiving a warning for every variable in the class. There is an example below showing the error in VS 2019. Im not sure why the error is coming up would someone be able to assist me

Severity Code Description Project File Line Suppression State Warning C26495 Variable 'orderRecord::orderTax' is uninitialized. Always initialize a member variable (type.6).

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

Description This is a program that reads the input off of a input file for order data, and outputs the resulting calculations of order tax and net cost and total cost onto the consol screen. *************************************************************/ #include #include #include using namespace std;

/********************************************************* //Following is the declaration of a order record **********************************************************/ class orderRecord { public: string cellNum; string itemNum; int quantity; double price; int locID; double taxRate; double orderTax; double netCost; double totalCost; };

//Declaration Prototypes for your functions will go here //BE SURE TO ADD COMMENTS TO THE FUNCTION PROTOTYPES AND THE FUNCTION DEFINITIONS //ADD the full comments to the function prototypes (pre and post conditions, and descriptions) //ADD brief descriptions to the function definitions

void GetInput(ifstream&, orderRecord&); //Precondition: State what is true before the function is called. //Postcondition: State what is true after the function has executed. //Description: Describe what the function does

void ProcessData(orderRecord&); //Precondition: State what is true before the function is called. //Postcondition: State what is true after the function has executed. //Description: Describe what the function does

void GetTaxRate(double&, int); //Precondition: State what is true before the function is called. //Postcondition: State what is true after the function has executed. //Description: Describe what the function does

void ScreenOutput(const orderRecord&); //Precondition: State what is true before the function is called. //Postcondition: State what is true after the function has executed. //Description: Describe what the function does

//HERE IS THE main function, a driver to test your program int main() { string name; cout << "Enter your first name: "; cin >> name; cout << name << ", Let's get started processing the file data." << endl;

orderRecord customerData;

ifstream in; //declaring an input file stream in.open("purchaseData.txt"); //connect to the input file

if (in.fail()) { cout << "Input file did not open correctly" << endl; } else { while (!in.eof()) //has not reached the end of the file { GetInput(in, customerData); //call ProcessData ProcessData(customerData); ScreenOutput(customerData); //call ScreenOutput } } cout << "Thank you " << name << "have a nice day!";

in.close();

return 0; }

//Function Implementations will go here

//Description: Pulls the values from input text file and inputs it into the coresponding variables void GetInput(ifstream& in, orderRecord& p_record) { in >> p_record.cellNum; in >> p_record.itemNum; in >> p_record.quantity; in >> p_record.price; in >> p_record.locID; //add more code to read the rest of the fields (itemNum, quantity, price and locID) into the //order record, p_record. }

//Description: Describe what the function does void ProcessData(orderRecord& p_record) { //Call the GetTaxRate function to get the tax rate //based on the p_record.locID GetTaxRate(p_record.taxRate, p_record.locID); //calculate the orderTax, netCost, and totalCost //of the p_record, example: p_record.taxRate p_record.orderTax = p_record.quantity * p_record.price * p_record.taxRate; p_record.netCost = p_record.quantity * p_record.price; p_record.totalCost = p_record.netCost + p_record.orderTax;

}

//Description: Sets the value of taxrate based of off the input of the location id from the input file void GetTaxRate(double& taxRate, int locID) { //use the location ID to set the tax rate if (locID >= 500 && locID <= 530) { taxRate = .04; } else if (locID >= 531 && locID <= 560) { taxRate = .06; } else if (locID >= 561 && locID <= 580) { taxRate = .066; } else if (locID >= 581 && locID <= 600) { taxRate = .07; } else if (locID > 600) { taxRate = .0825; } }

//Description: Describe what the function does void ScreenOutput(const orderRecord& p_record) {

//set the number of decimal places for doubles cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); //use any number her for the number of decimal places

// display the results here cout << p_record.cellNum << "\t" << p_record.itemNum << "\t" << p_record.quantity << "\t" << p_record.price << "\t" << p_record.locID << "\t" << p_record.taxRate << "\t" << p_record.orderTax << "\t" << p_record.netCost << "\t" << p_record.totalCost << endl; //\t for tab }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logistics Lifeline Supply Chain Strategies

Authors: Ehsan Sheroy

1st Edition

7419377502, 978-7419377503

More Books

Students also viewed these Databases questions

Question

9-5 How will MIS help my career?

Answered: 1 week ago

Question

Identify four applications of HRM to healthcare organizations.

Answered: 1 week ago