Question

In: Computer Science

In this assignment you are to make an inventory management system for a car dealership. The...

In this assignment you are to make an inventory management system for a car dealership. The dealerships current method of tracking inventory is using a list which has the color and name of each car they have in inventory. There current inventory list will look like the example below.

RED TOYOTA
WHITE HONDA
.
.
.
BLACK BMW

The types of cars that they order are as follows:

TOYOTA, HONDA, BMW, NISSAN, TESLA, DODGE

The colors they purchase are as follows:

RED, WHITE, BLUE, BLACK, GREY, PINK

You are to ask the user for the name of the file that holds the current inventory list. Once given to you, parse the list and populate a 2D array to track the number of cars with a certain type and color. All colors and types of car may not be present in the inventory list. You should also tell the user (in the terminal, use cout to print the message) if you come across a car type or color that you are not tracking. If you come across a car or color that you are not tracking do not store it in your new inventory database only notify the user that you found it, your output for this prompt should match the below example.

Prompt to show when you find something that you are not tracking:

Unknown car or color in the input file: <UNKNOWN CAR COLOR> <UNKNOWN CAR TYPE>

Once you are finished you have parsed the input file prompt the user for the name of the output file they would like you to store the new database in. The output file should follow the format given below (yes you will need to use iomanip to get this format).

| RED | WHITE | BLUE | BLACK | GREY | PINK | 
----------------------------------------------------
TOYOTA | 0 | 0 | 0 | 0 | 0 | 0 |
HONDA | 0 | 0 | 0 | 0 | 0 | 0 |
BMW | 0 | 0 | 0 | 0 | 0 | 0 |
NISSAN | 0 | 0 | 0 | 0 | 0 | 0 |
TESLA | 0 | 0 | 0 | 0 | 0 | 0 |
DODGE | 0 | 0 | 0 | 0 | 0 | 0 |

Solutions

Expert Solution

Below code written in C++ ....

#include<iostream>

#inclide<string>

#include<fstream>

using namespace std;

int car(string s) //function to map car name with array index

{

if(s.compare("TOYOTA")==0)

return 0;

else if(s.compare("HONDA")==0)

return 1;

else if(s.compare("BMW")==0)

return 2;

else if(s.compare("NISSAN")==0)

return 3;

else if(s.compare("TESLA")==0)

return 4;

else if(s.compare("DODGE")==0)

return 5;

else

return -1;

}

int color(string str) //function to map car color with array index

{

if(str.compare("RED")==0)

return 0;

else if(str.compare("WHITE")==0)

return 1;

else if(str.compare("BLUE")==0)

return 2;

else if(str.compare("BLACK")==0)

return 3;

else if(str.compare("GREY")==0)

return 4;

else if(str.compare("PINK")==0)

return 5;

else

return -1;

}

int main()

{

string inFile,outFile;

ifstream in;

ofstream out;

string str;

  

string CR[6]={"TOYOTA","HONDA","BMW","NISSAN","TESLA","DODGE"}; //initialization for car and color aray

string CL[6]={"RED","WHITE","BLUE","BLACK","GREY","PINK"};

int A[6][6]; //2D array to store inventory information

for(int i=0;i<6;i++) //initially 2D array is initialized with 0

for(int j=0;j<6;j++)

A[i][j]=0;

cout<<"Enter name of input file: ";

cin>>inFile;

in.open(inFile); //open input file

if(!in){

cout<<"Unable to open file "<<inFile<<endl;

return 0;

}

bool flag=false;

int row,col;

//read data from input file

while(in>>str)

{

if(flag==false)

{

row=car(str);

flag=true;

if(row==-1)

cout<<"Unknown car or color in the input file: "<<str<<endl;

}

else if(flag==true)

{

col=color(str);

flag=false;

if(row==-1 || col==-1)

cout<<"Unknown car or color in the input file: "<<str<<endl;

else

A[row][col]++;

}

}

cout<<"Enter the name of output file: ";

cin>>outFile;

out.open(outFile); //open output file

if(!out){

cout<<"Unable to open file "<<outFile<<endl;

return 0;

}

out<<"\t| ";

for(int i=0;i<6;i++) //write data to output file

out<<CL[i]<<" |";

out<<endl;

out<<"-------------------------------------------------------------"<<endl;

for(int i=0;i<6;i++)

{

for(int j=0;j<6;j++)

{

if(j==0)

out<<CR[i]<<"\t|";

out<<"\t"<<A[i][j]<<"|";

}

out<<endl;

}

in.close();

out.close();

return 0;

}

Input file : input.txt

TOYOTA RED

BMW BLUE

TOYOTA RED

BMW PINK

TOYOTA RED

NISSAN BLUE

TOYOTA RED

TESLA PINK

TOYOTA RED

BMW BLUE

TOYOTA WHITE

BMW BLACK

DODGE RED

NISSAN GREY

TOYOTA RED

TESLA PINK

MARUTI MAGENTA

Output file : output.txt

RED WHITE BLUE BLACK GREY PINK
TOYOTA 6 1 0 0 0 0
HONDA 0 0 0 0 0 0
BMW 0 0 2 1 0 1
NISSAN 0 0 1 0 1 0
TESLA 0 0 0 0 0 2
DEDGE 1 0 0 0 0 0

Sample output looks like :

Enter name of input file : input.txt

Unknown car or color in the input file : MARUTI

Unknown car or color in the input file : MAGENTA

Enter name of output file : output.txt


Related Solutions

What type of queuing system is used at a: restaurant? car dealership? Zappos?
What type of queuing system is used at a: restaurant? car dealership? Zappos?
in java pls Write a Car Dealership management program. This program will allow the employees of...
in java pls Write a Car Dealership management program. This program will allow the employees of the Dealership to add cars to their database and sell them. You will be implementing two classes: Car and CarDealership. Car will store data associated with the cars and CarDealership will be the management program. Note: 5 points of your grade is based on Coding Style. You will need to update the Starter Code to follow the standards described here. Use the "Run" button...
A car dealership offers you no money down on a new car. You may pay for...
A car dealership offers you no money down on a new car. You may pay for the car for 5 years by equal monthly end-of-the-month payments of $407 each, with the first payment to be made one month from today. If the discount annual rate is 4.52 percent compounded monthly, what is the present value of the car payments? Round the answer to two decimal places.
Calvin borrows $20,000 from a car dealership to purchase a vehicle. The car dealership charges 12%...
Calvin borrows $20,000 from a car dealership to purchase a vehicle. The car dealership charges 12% interest, compounded monthly. Calvin is expected to pay off the loan principal and all interest charged with equal monthly payments over a 3-year period. a. What will Calvin’s monthly payment need to be? (4 points) b. With the first monthly payment, how much of this payment will be “interest”, and how much of this payment will be “principal”? (4 points) c. Once the loan...
Calvin borrows $20,000 from a car dealership to purchase a vehicle. The car dealership charges 12%...
Calvin borrows $20,000 from a car dealership to purchase a vehicle. The car dealership charges 12% interest, compounded monthly. Calvin is expected to pay off the loan principal and all interest charged with equal monthly payments over a 3-year period. a. What will Calvin’s monthly payment need to be? (4 points) b. With the first monthly payment, how much of this payment will be “interest”, and how much of this payment will be “principal”? (4 points) c. Once the loan...
We are to make a program about a car dealership using arrays. I got the code...
We are to make a program about a car dealership using arrays. I got the code to display all cars in a list, so I'm good with that. What I'm stuck at is how to make it so when a user inputs x for search, it allows them to search the vehicle. We need two classes, one that shows the car information and another that shows the insert, search, delete, display methods. Here is what I have so far package...
1/ Assume you purchased a car that costs $14,000. The car dealership is offering financing at...
1/ Assume you purchased a car that costs $14,000. The car dealership is offering financing at 5% per year. How much is your annual payment assuming you financed the car for 5 years? How much did the car actually cost? 2/ At the beginning of the season on April 1, Green Acres Golf Course completed a physical inventory count and found that $3,000 of inventory was still on hand. Throughout the month of April, Green Acres had the following purchase...
Assignment 4 You will be writing an inventory system that is backed by JSON data and...
Assignment 4 You will be writing an inventory system that is backed by JSON data and will be working with a starter file that contains a JSON string. The code you write will need to follow the following guidelines. You’re at work one day and your boss asks you about that fancy programming language you’ve been learning, Python. She asks you if you can use it to read JSON data from a supplier and build an inventory. “Of course!” you...
Python Assignment You will be writing an inventory system that is backed by JSON data and...
Python Assignment You will be writing an inventory system that is backed by JSON data and will be working with a starter file that contains a JSON string. The code you write will need to follow the following guidelines. The what You’re at work one day and your boss asks you about that fancy programming language you’ve been learning, Python. She asks you if you can use it to read JSON data from a supplier and build an inventory. “Of...
In the previous lab you created a Car class and a Dealership class. Now, in this...
In the previous lab you created a Car class and a Dealership class. Now, in this activity change the design of the Dealership class, in which the list of the cars inside a dealership will be stored in an ArrayList. Then, provide required getter and setter methods to keep the records of all its cars. In your tester class, test your class and also printout the list of all cars of a given dealership object. // Java program import java.util.ArrayList;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT