Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Main.cpp #include #include #include using namespace std; struct Date{ int day; int month; int year; }; struct Dimension{ double width; double height; double depth; };

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Main.cpp
#include
#include
#include
using namespace std;
struct Date{
int day;
int month;
int year;
};
struct Dimension{
double width;
double height;
double depth;
};
struct Furniture{
string name;
string color;
int inventory;
Date dateCreated;
double cost;
};
struct Art{
string name;
double cost;
int inventory;
Date dateCreated;
Dimension artSize;
};
struct Fabric{
string name;
string color;
int inventory;
double cost;
};
struct Book{
string name;
bool hardCover;
int numPages;
double cost;
int inventory;
Date datePublished;
};
/**
These four functions are mandatory as instructed in the Assignment
**/
void getFurnitureData(ifstream& inFile);
void getArtData(ifstream& inFile);
void getFabricData(ifstream& inFile);
void getBookData(ifstream& inFile);
/**
Optional Helper Functions
**/
void displayFurniture(Furniture furniture[], int totalFurniture);
void displayArt(Art art[], int totalArt);
void displayFabric(Fabric fabric[], int totalFabric);
void displayBook(Book book[], int totalBook);
void printHorizontalLine( int width, char border_char);
void printHeading( string title, int width );
int main()
{
cout
/**
Declaring the input streams for each file
**/
ifstream inFileFurniture;
ifstream inFileArt;
ifstream inFileFabric;
ifstream inFileBook;
/**
Opening the files. You can either hardcode the name of the files or ask the user to give the names
**/
inFileFurniture.open("Furniture.txt");
inFileArt.open("Art.txt");
inFileFabric.open("Fabric.txt");
inFileBook.open("Book.txt");
/**
If the any of the file cannot be opened then the program terminates displaying
the error message
**/
if (!inFileFurniture)
{
cout
//return 1;
}
if (!inFileArt)
{
cout
return 1;
}
if (!inFileFabric)
{
cout
return 1;
}
if (!inFileBook)
{
cout
return 1;
}
/**
Display the prompt and do the requested action. Keep repeating the prompt until exit.
If the number entered is not an option, just repeat the prompt.
**/
int chosenOption;
do{
cout
cin >> chosenOption;
/**
Do the correct action according to the chosenOption
**/
switch(chosenOption)
{
case 1:
/**
Furniture
Function call to read data from input file. That function then calls a print Function
**/
getFurnitureData(inFileFurniture);
break;
case 2:
/**
Art
Function call to read data from input file. That function then calls a print Function
**/
getArtData(inFileArt);
break;
case 3:
/**
Fabric
Function call to read data from input file. That function then calls a print Function
**/
getFabricData(inFileFabric);
break;
case 4:
/**
Book
Function call to read data from input file. That function then calls a print Function
**/
getBookData(inFileBook);
break;
default:
break;
}
}while(chosenOption != 5);
return 0;
}
void printHorizontalLine( int width, char border_char){
cout.fill( border_char );
cout
cout.fill(' ');
}
void printHeading( string title, int width ){
//Declare Variables
int magic_width = 0;
magic_width = (width/2) - (title.length()/2) + title.length();
cout
cout
cout
cout
//reset count
cout.clear();
cout.fill(' ');
//VOID functions do NOT return a value
}
/**
Using the input stream sent as parameter we are reading the content from the Furniture.txt and storing it in the Furniture struct array
**/
void getFurnitureData(ifstream& inFile){
int totalFurniture;
inFile >> totalFurniture;
Furniture furniture[totalFurniture];
char decimal;
for(int i = 0; i
inFile >> furniture[i].name;
inFile >> furniture[i].color;
inFile >> furniture[i].inventory;
inFile >> furniture[i].dateCreated.month >> decimal >> furniture[i].dateCreated.day >> decimal >> furniture[i].dateCreated.year;
inFile >> furniture[i].cost;
}
inFile.close();
printHeading("Furniture", 60);
displayFurniture(furniture,totalFurniture);
}
/**
Using the input stream sent as parameter we are reading the content from the fabric.txt and storing it in the fabric struct array
**/
void getFabricData(ifstream& inFile){
int totalFabric;
inFile >> totalFabric;
Fabric fabric[totalFabric];
for(int i = 0; i
inFile >> fabric[i].name;
inFile >> fabric[i].color;
inFile >> fabric[i].inventory;
inFile >> fabric[i].cost;
}
inFile.close();
printHeading("Fabric", 60);
displayFabric(fabric,totalFabric);
}
/**
Using the input stream sent as parameter we are reading the content from the Art.txt and storing it in the art struct array
**/
void getArtData(ifstream& inFile){
int totalArt;
inFile >> totalArt;
Art art[totalArt];
char decimal;
for(int i = 0; i
inFile >> art[i].name;
inFile >> art[i].cost;
inFile >> art[i].inventory;
inFile >> art[i].dateCreated.month >> decimal >> art[i].dateCreated.day >> decimal >> art[i].dateCreated.year;
inFile >> art[i].artSize.width >> decimal >> art[i].artSize.height >> decimal >> art[i].artSize.depth;
}
inFile.close();
printHeading("Art", 60);
displayArt(art,totalArt);
}
/**
Using the input stream sent as parameter we are reading the content from the Personnel.txt and storing it in the Book struct array
**/
void getBookData(ifstream& inFile){
int totalBook;
inFile >> totalBook;
Book book[totalBook];
char decimal;
for(int i = 0; i
inFile >> book[i].name;
inFile >> book[i].hardCover;
inFile >> book[i].numPages;
inFile >> book[i].cost;
inFile >> book[i].inventory;
inFile >> book[i].datePublished.month >> decimal >> book[i].datePublished.day >> decimal >> book[i].datePublished.year;
}
inFile.close();
printHeading("Books", 60);
displayBook(book,totalBook);
}
/**
Displaying the content from the Furniture struct array on the monitor
**/
void displayFurniture(Furniture furniture[], int totalFurniture){
cout
printHorizontalLine(80,'-');
for(int i = 0; i
cout
}
}
/**
Displaying the content from the Fabric struct array on the monitor
**/
void displayFabric(Fabric fabric[], int totalFabric){
cout
printHorizontalLine(80,'-');
for(int i = 0; i
cout
}
}
/**
Displaying the content from the Art struct array on the monitor
**/
void displayArt(Art art[], int totalArt){
cout
printHorizontalLine(80,'-');
for(int i = 0; i
cout
}
}
/**
Displaying the content from the Personnel struct array on the monitor
**/
void displayBook(Book book[], int totalBook){
cout
printHorizontalLine(80,'-');
for(int i = 0; i
cout
}
}
AT&T 12:58 PM 45% Assg-4 Description.pdfT Assg-4 Description.pdf 1 of 2 Assignment #4 Problem Solving and Depertment of Computer Science Old Dominion Eniversin Obiectives The main objective of this assignment is checking students' ability to implement membership functions. After completing this assignment, students will be able to: implement member fanctions e convert a member fianction into a standalone function e convert a standalone function into a member function call member functions .use structs for function overleading Notes: . Please note that this assignment is split imo two parts (Part-4 and Part-B) For this assignment you will create two projects and sabmit two zipped is(AssgA clogin and Assg4B cslogin) containing your code for the two parts. Part-A (85 marks) Problem description. In this asignment, we will revisit Assignment #1 "the aanple of home decoration company that is altempting to run its storehonse more eficiently. You will need to modify the program such that the company can make some critical decisions, including processing the received inventory of art, books, furniture, and fabric. This assignment needs the structs art, books, furniture, tabric, date, and dimension. Precessing inventory The company wants to oeganize ins inventory by cost from least to greatest. If the price of two items is the same, either one can be displayed first. You mast use a member function of the approperiate corresponding atruct to perform the comparison. Lastly print all items in order by cost You will need to save the output into a You must use constructors to initialire all data variables in strueta with default values at the beginning of the program. Use of global variables will incur a deduction of 10 points from your total points. Please check the attached "Grading Rubric" for the grading eriteria text file named SequencedOrders.tt. .Submit the entire project folder which includes all files from your project, especially the pp, h and chp filets) . Zip the project folder and name it as "Assg4A cslogin", where the cslogin is your login ID for the computers at the Department of Compater Science at ODU. To zip the folder, Right click on

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

Sql++ For Sql Users A Tutorial

Authors: Don Chamberlin

1st Edition

0692184503, 978-0692184509

More Books

Students also viewed these Databases questions