Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 ( 0 % ) This workshop consists of two modules: w 1 ( partially supplied ) Food Order w 1 Module ( partially

Part 1(0%)
This workshop consists of two modules:
w1(partially supplied)
Food Order
w1 Module (partially supplied)
Study the code supplied and make sure you understand it.
Finish the implementation of the main function, by completing the parts marked with TODO:
write the prototype of the main function to receive a set of standard command line arguments
echo the set of arguments to standard output in the following format:
1: first argument
2: second argument
3: third argument
4: ...
Do not modify this module in any other place!
FoodOrder Module
The FoodOrder module defines the current tax rate and daily special discount, as two global variables named g_taxrate and g_dailydiscount that stores double values. The value of the tax rate and daily discount may change from day to day. These two variables will be accessed when a new day of orders starts from the main function.
This module also defines a class named FoodOrder in the namespace seneca that stores some information about an order of food:
a C-style null-terminated string of up to 10 characters including the null byte terminator representing the name of the customer ordering the food.
a C-style null-terminated string of up to 25 characters including the null byte terminator representing the description of the food.
the price of the food represented by a double value.
a boolean flag indicating whether or not the order is a daily special
Public Members
Default constructor
read(): a modifier that receives an istream reference.
If the istream is in a good state, this function will attempt to read from the istream and store the information read into current object. The data read in will be in the following format:
,,,[newline]
The daily special status can be of two values: 'Y' for it is a special and 'N' for it is not.
If the istream object is not in a good state then this function will do nothing.
When implementing the read function it may be advisable to review the Input/Output Objects chapter from the 200/244 Course Notes.
display(): a query that displays to the screen the content of an Food Order instance in the following format:
COUNTER. Name |Order Description |Price w/Tax |Special Price
If no customer name has been stored in the current object, this query should print:
COUNTER. No Order
where
COUNTER is a left aligned field of size 2, that holds the number of times that this function has been called (use a local-to-function variable that remains in memory for the lifetime of the program) Do not use global/member variables to store the counter!
Name is a left aligned field of size 10 that represents the name of the customer that made the order.
Order Description is a left aligned field of size 25 that represents the description of the food ordered.
Price w/Tax is a left aligned field of size 12 with 2 decimal point precision that represents the price of the food ordered with tax calculated based on the current tax rate.
Special Price is a right aligned field of size 13 that represents the taxed price of the food ordered with the daily discount applied on top if the order was a daily special. If the order isn't a daily special then nothing is printed here.
Add any other private members that your design requires (without changing the specs above)!
Sample Output
The input files day1.txt and day2.txt are already provided; the main module contains a description of the structure for these files.
When the program is started with the command:
ws day1.txt day2.txt
the output should look like the one from the sample_output.txt file.
Test Your Code
To test and demonstrate execution of your program use the same data as shown in the output example above.
Upload your source code to your matrix account. Compile and run your code using the latest version of the g++ compiler (available at /usr/local/gcc/10.2.0/bin/g++) and make sure that everything works properly.
Then, run the following command from your account (replace profname.proflastname with your professors Seneca userid):
~profname.proflastname/submit 345_w1_p1
and follow the instructions.
This part represents a milestone in completing the workshop and is not marked!
Part 2(100%)
For this part of the workshop, upgrade your FoodOrders class to accept an food description in the form of a C-style null-terminated string of any length. Make sure your program doesn't have memory leaks.
In order to facilitate the changes needed for this part, consider the use of these std::string related functions:
std::getline
std::string::c_str
std::string::length
Sample Output
When the program is started with the command:
ws day1.txt missing.txt day2.txt
the output should look like the one from the sample_output.txt file.

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

110. Let X have the pdf fX(x) 2/x3, x 1. Find the pdf of .

Answered: 1 week ago