stainless steel factory is producing three different products (SS111, SS222, SS3
ID: 3819409 • Letter: S
Question
stainless steel factory is producing three different products (SS111, SS222, SS333). Write a c program that reads a dealer's order information from a text file and generates the invoice for and that dealer. The item selling prices are 120.0 OMR, 59.5 OMR and To.7 oMR for SS111, SS222 ss333 accordingly. Download order txt file from Moodle required from The order txt file contains the customer name, product ID and quantity name. each product type. The first line of the file contains the dealer's company Your program should implement the following three functions: Total Quantity function: void function that receives the product ID and the quantity from the order list and counts the total quantity for each product. This function also check for unknown product IDs and display error message accordingly. void (string proID, int quantity) Preferred Product function: String return function that receives the total quality of each product and it returns the product ID with maximum quantity value. string Preferred Product (int tot ID1, int tot ID2, int tot ID3) Print Invoice function: void function that receives the total quantity of each product and it calculates and displays the invoice for the dealer. void Print Invoice (int tot ID1, int tot ID2, int tot ID3) 3 order .Notepad lease enetr order file nane: order.txt File Edit Format View Help Note: Unknown product ID SS123 Ignored AIASARI TRADING Customer A SS111 50 Stainless Steel Factory Customer A SS222 100 Customer A SS333 80 Client: AlASARI TRADING Quantity Total (ORR) Customer B SS111 80 Product Customer B SS222 40 31200.00 Customer C SS111 60 22215.00 370 SS222 20503.00 SS333 Customer C SS222 1500 Customer C SS333 120 73718.00 ORR Customer C SS123 40 Customer D SS111 70 prefered prodkut ss222 Press any key to continue Custoner D SS222 80 Customer D SS333 90 Your program should check for input file errors and display appropriate message. Your program should check for unknown product IDs and display appropriate message. Your program should display the output to the output screen according to the format shown in above sampleExplanation / Answer
#pragma once
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class Car
{
private:
string name;
string color;
double price;
public:
Car(string name_in, string color_in, double price_in);
virtual ~Car();
string getName();
string getColor();
double getPrice();
void paint(string new_color);
string toString();
};
#include "car.h"
using namespace std;
Car::Car(string name_in, string color_in, double price_in)
{
name = name_in;
color = color_in;
price = price_in;
}
Car::~Car() {}
string Car::getName()
{
return name;
}
string Car::getColor()
{
return color;
}
double Car::getPrice()
{
return price;
}
void Car::paint(string new_color)
{
color = new_color;
price += 1000;
}
string Car::toString()
{
stringstream ss;
ss << "Name: " << name << endl;
ss << "Color: " << color << endl;
ss << "Price: $" << price << endl;
return ss.str();
}
#include <iostream>
#include "car.h"
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
using namespace std;
int main()
{
int option;
string name;
string color;
double price = 0;
double balance = 10000;
Car cars(name, color, price);
do
{
cout << "Please select an option:" << endl;
cout << "1 - Show current inventory." << endl;
cout << "2 - Show current balance." << endl;
cout << "3 - Buy a car." << endl;
cout << "4 - Sell a car." << endl;
cout << "5 - Paint a car." << endl;
cout << "6 - Load file." << endl;
cout << "7 - Save file." << endl;
cout << "8 - Quit program." << endl;
cout << " ";
cin >> option;
if (option == 1)
{
cout << cars.toString();
}
if (option == 2)
{
cout << "$" << balance << endl;
}
if (option == 3)
{
cout << "Please enter the name, color, and price of the car you would like to buy." << endl;
cin >> name;
cin >> color;
cin >> price;
if (price <= balance)
{
cout << "Car has been purchased." << endl;
balance = balance - price;
}
else
{
cout << "You cannot afford that car." << endl;
option = 0;
}
}
if (option == 4)
{
cout << "Please enter the name of the car you want to sell." << endl;
cin >> name;
balance = balance + price;
}
if (option == 5)
{
}
if (option == 6)
{
ifstream fin;
fin.open("cars1.txt");
}
if (option == 7)
{
ofstream fout;
fout.open("Lab 8.txt");
fout << cars.toString() << endl;
fout << "$" << balance << endl;
}
if (option == 8)
{
exit(0);
}
if (option < 0 || option > 8)
{
cout << "Please enter a number from 1-8." << endl;
}
cout << " ";
} while (option < 8 || option > 8);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.