Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

REQUIREMENT: Provide one application for a business store that sale 2 models of one product, model A and model B. The application first provides the

REQUIREMENT:

Provide one application for a business store that sale 2 models of one product, model A and model B. The application first provides the menu to allow users can select one of the following tasks per time and when they finish one task, they can continue to using the application to select other task from the menu until they choose exit. All the output on the screen and in files should be exact as requested

MENU

1. Sale Product

2. Ending day sale report

3. Ending month sale report

4. Ending year sale report

0. Exit

Task1: Sale Product:

For each sale transaction, after entering the sale transaction number (string), number of Model A units sold (int),price of model A unit (double), the number of model B (int), the price of model B unit (double), the amount paid of customer (double) from the keyboard, the application should print the receipt on the screen and write one line to the file name SaleInDay_yyyy_mm_dd.txt.

The receipt is in the following format (the first transaction in the below example:

* Write one line to output file:

For example, on day 06/26/2016, each sale transaction will be written on one line in the file named

SaleInDay_2016_06_26.txt. Each line includes 5 information separated by a tab \t

-The first column: transaction number

-The second column is number of model A units sold,

-The third column is the price of model A unit

-The fourth column is number of model B units sold,

-The last column is the price of model B unit

2601 12 1.99 10 2.19

2602 8 1.99 12 2.19

2603 14 1.99 14 2.19

2604 9 1.99 11 2.19

2605 13 1.99 16 2.19

2606 11 1.99 10 2.19

2607 7 1.99 12 2.19

2608 8 1.99 16 2.19

2609 12 1.99 15 2.19

2610 15 1.99 18 2.19

Task2: Ending day sale report:

-At the end of the day, users will run task 2 to calculate subtotal of sale during the day.

* open and read the file Sale_yyyy_mm_dd.txt that is created from the task 1.

* For each line: calculate the money of model A sold and the money of model B sold on each sale transaction, thenadd up to have sum of number model A units sold, sum of money model A sold, sum of number model B units sold,sum of money model B sold and total money sold both model sold during the day

* display the report of the day on the screen and write one line to the output file to file SaleInMonth_yyyy_mm.txt

For example: on the day 06/26/2016, there are 10 sale transaction in above file Sale_2016_06_26.txt

The output of the Day Sale Report on the screen a below:

216.91 (total money sold model A whole day)= moneyA of transaction1 + moneyA of transaction 2+ . +monye of transaction 10

293.46 (total money sold model B whole day)

= moneyB of transaction1 + moneyB of transaction 2+ . +money of transaction 10

This is an example of file SaleInDay_yyyy_mm_dd.txt

That has 10 sale transactions during the day.

You can use it for testing the task 2

The bold line is result from the example

moneyA of each transaction = number of modelA units (2nd column) * price of unit A (3rd column)

moneyB of each transaction = number of modelB units (4th column) * price of unit B (5th column)

109 (total A units sold in whole day) = sum of 2nd column

234 (total B units sold in whole day) = sum of 4th column

510.37 (total money sold in the day)

= total money sold model A whole day + total money sold model B whole day

These above information of each day sold will be saved on one line in the file SaleInMonth_2016_06.txt with 5information that are separated by a tab \t as below

*The 1st column is the day of the month

*The 2nd column is the number of model A sold on each day

*The 3rd column is the money sold model A on each day

*The 4thcolumn is the number of model B sold on each day

*The last column is the money sold model B on each day

1 72 143.28 98 214.62

2 85 169.15 106 232.14

3 91 181.09 97 212.43

4 78 170.82 92 210.68

5 87 190.53 105 240.45

6 88 192.72 110 251.90

7 93 175.77 98 204.82

8 85 160.65 96 200.64

9 90 170.1 93 194.37

10 88 175.12 101 221.19

11 76 151.24 105 229.95

12 94 187.06 120 262.80

13 89 177.11 115 251.85

14 96 191.04 103 225.57

15 87 173.13 118 258.42

16 79 157.21 112 245.28

17 94 187.06 103 225.57

18 84 167.16 105 229.95

19 76 151.24 122 267.18

20 94 187.06 107 234.33

21 89 177.11 113 247.47

22 92 183.08 108 236.52

23 93 185.07 104 227.76

24 88 175.12 102 223.38

25 94 187.06 116 254.04

26 109 216.91 134 293.46

27 90 179.10 108 236.52

28 88 175.12 114 249.66

29 96 191.04 104 227.76

30 86 171.14 110 240.90

3.Task Ending Month Sale report:

-At the end of each month, based on the information that was stored in the files from task2 (file

SaleInMonth_yyyy_mm.txt), the users will calculate the subtotal for the month, print out the report on the screenand write one line to the file SaleInYear_yyyy.txt

For example:

On June 2016, there is 30 sale days, each line contains the information of each day in file SaleInMonth_2016_06.txt

*The output on the screen as follows:

This is an example of file SaleInMonth_yyyy_mm.txt

That has 30 sale transactions during the month.

You can use it for testing the task 3

The bold line is result from the example

2651 (total model A units sold in month) = subtotal of 2nd column

5299.29 (total money sold model A in month) = subtotal of 3rd column

3219 (total model B units sold in month) = subtoal of 4th column

7051.61 (total money sold model B in month) = subtotal of the last column

12350.90 = money sold model A in month + money sold model B in month = 5288.29 + 7051.61

*The file name of output file is SaleInYear_yyyy.txt where yyyy is current year

For example, at the end of the year 2016, the file SaleInYear_2016.txt will have 12 lines. Each month, the abovetask writes one line

There are 12 lines of 12 months

-The first column is the month

-The second column is number of model A sold in one month

-The third column is the money of model A sold in one month

-The fourth column is number of model B sold in one month

-The last column is the money of model B sold in one month

Between these columns, there is one tab \t

01 2777 5526.23 3223 7058.37

02 2431 4837.69 2612 5720.28

03 2540 5054.6 2729 5976.51

04 2557 5088.43 2892 6333.48

05 2515 5004.85 2249 4925.31

06 2651 5299.29 3219 7051.61

07 2610 5193.9 2839 6217.41

08 2595 5164.05 2875 6296.25

09 2456 4887.44 2828 6193.32

10 2454 4883.46 2803 6138.57

11 2707 5386.93 3295 7216.05

12 2893 5757.07 3522 7713.18

Task Ending Year sale report:

-At the end of year, based on the information of file SaleInYear_2016.txt to provide the report on the screeen asbelow:

31186 (total model A units sold in year) = subtotal of 2nd column

62083.94 (total money sold model A in year) = subtotal of 3rd column

35086 (total model B units sold in year) = subtotal of 4thcolumn

62083.94 (total money sold model B in year) = subtotal of last column

138924.28 (total money sold both models in year)

= money sold model A in year + money solde model B in year = 62083.94 + 76840.34

This is an example of file SaleInMonth_yyyy.txt

That has 12 lines for 12 months

You can use it for testing the task 4

The bold line is result from the example

WHAT WE NEED TO KNOW TO DO THE PROGRAM

To do this project you should review the following:

-How to open file to read, how to read the file

-How to open file to append, how to write one line to the text file

-How to get the current date read the topic HOW TO GET CURRENT DATE from the page Learn From

Questions on eCampus

#include

//date will be in the format: 06/26/16

char currentDate[10];

_strdate(currentDate);

string date(currentDate);

cour << date: << date << endl;

-How to get a substring from a string: read the topic HOW TO GET A SUBSTRING FROM A STRING from the

page Learn From Questions on eCampus

string date = 06/26/16;

//temp1 = 06/26/

String temp1 = date.substr(index start, number of character in substring) = date.substr(0,6)

//temp2 = 16

String temp2 = date.substr(index start) = date.substr(6); //from index6 to the end

-How to concatenate string:

string year = 20 + temp2; // year = 2016

string newDate = temp1 + 20 + temp2; // newDate = 06/26/2016

-How to find a character in a string: using find function

Example: string line = 01 2777 5526.23 3223 7058.37;

There is a tab \t between these numbers

int pos = line.find(\t); // pos = 2 the first tab in line

Then you can extract the first information:

string first = line.substr(0,2); // first = 01

line = line.substr(pos+1); //line = 2777 5526.23 3223 7058.37;

keep doing the same way we can extract each number and assign to different variables to be used

-How to convert a numeric string to a number. Read the topic Convert a numeric string to a number Using

atoi or atof from the page Learn From Questions on eCampus

String temp1 = 34;

String temp2 = 22.75;

Int num = stoi(temp1); // num = 34

double num2 = stof(temp2); // num2 = 22.75

-How to create a user-defined function. Read the topic Function: Predefined function and User-defined

functions from the page Learn From Question on eCampus

-How the reference parameter of a user-define function works. Read the topic Read the topic REFERENCE

PARAMETERS through USER DEFINED FUNCTIONS from the page Learn From Question on eCampus

-How to manage the menu to allow users to continue using the program until they want to exit Read the topic

Redisplay the menu by using do.. while loop from page Learn From Questions on eCampus

PSUEDO-CODE

You have to provide the pseudo-code. It could be long, therefore, you can use word document to write the

pseudo_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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

What are Treasury bonds? Describe their key characteristics.

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago