Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ ************(PLEASE READ THE ENTIRE DIRECTIONS BEFORE TRYING TO ANSWER)************* ************************************************************************************************* ************************************************************************************************* Somebody Please Please Please Help me with this... I have done a lot

C++

************(PLEASE READ THE ENTIRE DIRECTIONS BEFORE TRYING TO ANSWER)*************

************************************************************************************************* *************************************************************************************************

Somebody Please Please Please Help me with this... I have done a lot of the work just need to get everything in the correct spot. We CAN NOT use Strings!!!!!

The Items Description MUST BE read into a Char array... I am assuming with getline().

Instead of opening and closing the input file for each requested item, open the stock.txt file, READ ALL THE VALUES FOR THE 9 STOCK ITEMS INTO THREE PARALLEL ARRAYS, then close the input file. When the user gives you a stock number you should search the arrays for the match and the corresponding description and price.

Use a file called Stock.txt that contains information regarding the 9 different stock items carried by DOLLAR SAVER INCORPORATED. The file is a repeating sequence of three records such that the first record represents an item code number, the second record represents the description of each item and the third record contains the current selling price. Then the sequence repeats. Your program is to simulate the checkout register allowing the check out clerk to input item codes to obtain the current selling prices and descriptions. If an incorrect code is entered, the clerk should be notified by an appropriate message on the screen. If the item is found, the clerk will enter the number of items with that description and price and continue to the next item. When all items have been entered the clerk terminates the transaction by entering an item code of 0 (zero). The program will build a sales slip called Sales.txt enumerating the item code, description, unit price, quantity purchased, and total extended price. The bill will be subtotaled and an 8% sales tax added for a final total. Amount tendered by the customer and change given will be finally added to the invoice. This invoice should be written out to an output file called Sales.txt. The final total and change should appear on the screen as well. Your output file should line up all columns and output formatted for dollars and cents on money amounts, using setprecision, showpoint, and fixed. Make sure you format your output to the screen as well. This assignment uses file processing found in chapter 5 and arrays found in chapter 7 of Starting Out With C++.

I just can't grasp this to figure out what I am doing wrong. Any and all help is greatly appreciated and if you can help me figure it out I will review you to fullest extent possible.

Thank You in Advance.

Input file:

stock.txt

1234 Stockings 12.39 2865 Pajamas 17.99 4020 Dress 23.00 3640 Sweater 20.50 5109 Shorts 56.99 4930 TV 88.20 6600 ToothBrush 94.55 5020 AluminumPan 16.79 2336 Pencils 4.55

My code so far:

[code]

#include

#include

#include

#include

using namespace std;

const int NUM_ITEMS = 9;

const int MAX_STRING_SIZE = 20;

int itemNum_Array[9];

char description_Array[9][20];

double price_Array[9];

int i,x;

int main ()

{

int itemNumber;

int itemNum;

string description;

float price;

int amt;

float total = 0;

float subtotal;

ofstream outputFile( "Sales.txt" );

outputFile << "FUNNY STUFF RETAIL, INC." << endl;

outputFile << endl;

ifstream inputFile;

inputFile.open("Stock.txt");

int indexCount;

indexCount = 0;

const int AR_SIZE = 9;

while (inputFile && indexCount < AR_SIZE)

{

inputFile >> itemNum[indexCount];

cin.ignore(100,' ');

getline(inputFile, description[indexCount]);

cout << endl;

inputFile >> price[indexCount];

cin.ignore(100,' ');

indexCount++;

}

}

if ( !inputFile )

{

cout << "The file (stock.txt) Failed to open." << endl;

return 0;

}

for (int x = 0; x < 9; x++)

{

inputFile >> itemNum_Array[x] >> description_Array[x] >> price_Array[x];

}

inputFile.close();

while( true )

{

cout << "Please give me an item number that you would like me to look up ? (0 when done)" << endl;

cin>> itemNum;

if ( itemNum == 0 ) break;

bool found = false;

for (int i = 0; i < 9; i++){

if (itemNum == itemNum_Array[i])

{

found = true;

break;

}

}

if ( found )

{

cout << fixed << showpoint << setprecision (2);

cout << "Item number : " << itemNum << " is pulling up : " << description << ", at $" << price << " per Item." << endl;

cout << "How many " << description << " would you like to purchase? " << endl;

cin >> amt;

total = total + ( amt * price );

found = false;

outputFile << "Item Number : " << itemNum << endl;

outputFile << "Item Description : " << description << endl;

outputFile << "Price per Item : $" <

outputFile << "Amount Purchased : " << amt << endl;

outputFile << "Item Subtotal : $" << (amt * price) << endl;

outputFile << endl;

cout << "OK, I've added " << amt << " " << description << " to your order." << endl;

}

else

{

cout << "I'm sorry, but we do not appear to carry that item in stock." << endl;

}

}

outputFile << fixed << setprecision( 2 );

cout << fixed << setprecision( 2 );

cout << fixed << showpoint << setprecision (2);

outputFile << "Combined Subtotal : $" << total <

subtotal = total;

outputFile << fixed << showpoint << setprecision (2);

outputFile << "Tax : $" << (total * .08)<

total = total + (total * .08);

outputFile << fixed << showpoint << setprecision (2);

outputFile << "Total : $" << total <

cout << fixed << showpoint << setprecision (2);

cout << "Your total comes to : $" << total << endl;

cout << "How much would you like to pay? " << endl;

float money, moreMoney, change;

cin >> money;

while ( money + moreMoney <= total )

{

cout << "I'm sorry, but that is not enough money to cover the total. How much more are you going to pay : ";

cin >> moreMoney;

}

change = money - total;

outputFile << fixed << showpoint << setprecision (2);

outputFile << "Amount Tendered : $" << money + moreMoney <

change = money + moreMoney - total;

cout << "Your change is : $" << change << endl;

outputFile << "Your change is : $" << change << endl;

cout << fixed << showpoint << setprecision (2);

cout << "Your change is : $" << change << endl;

outputFile << endl;

outputFile << "Thank You for Shopping with Us" <

outputFile << "Have a Great Day !" <

outputFile.close();

return 0;

}

[/code]

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

More Books

Students also viewed these Databases questions

Question

Discuss the importance of workforce planning.

Answered: 1 week ago

Question

Differentiate between a mission statement and a vision statement.

Answered: 1 week ago