Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is C++ program ....please repost the code after solving the errors in the program #include #include #include using namespace std; // Global Variables string

this is C++ program ....please repost the code after solving the errors in the program

#include

#include

#include

using namespace std;

// Global Variables

string inv_no;

string inv_date;

string cust_name;

string cust_address;

float total_amt;

float tax_amt;

float discount;

float advance;

// Function Definitions

void main_menu();

void new_invoice();

void new_company();

void new_customer();

void new_order();

void get_item();

void update();

void print(); void printInv();

class Invoice {

public:

// New Invoice

void new_invoice() {

// Input invoice number, date and customer name

cout << "Enter invoice number: ";

cin >> inv_no;

cout << "Enter invoice date: ";

cin >> inv_date;

cout << "Enter customer name: ";

cin >> cust_name;

// Open file

ofstream inv_file;

inv_file.open("Invoice.txt", ios::out | ios::app);

// Write to file

inv_file << inv_no << " " << inv_date << " " << cust_name << endl;

// Close file

inv_file.close();

}

};

int main() {

Invoice invoice;

invoice.inv_no = "12345";

invoice.inv_date = "2022-01-01";

invoice.cust_name = "John Smith";

invoice.cust_address = "123 Main St.";

invoice.total_amt = 100.00;

invoice.tax_amt = 5.00;

invoice.discount = 10.00;

invoice.advance = 20.00;

invoice.print();

main_menu(); return 0;

}

// Print Invoice

void print() {

// Open file

ifstream inv_file;

inv_file.open("Invoice.txt");

// Read and display file contents

cout << "Invoice details:" << endl;

while (inv_file >> inv_no >> inv_date >> cust_name) {

cout << inv_no << " " << inv_date << " " << cust_name << endl;

}

// Close file

inv_file.close();

}

// New Company

void new_company() {

// Input company name, address and layout

string comp_name;

string comp_address;

string layout;

cout << "Enter company name: ";

cin >> comp_name;

cout << "Enter company address: ";

cin >> comp_address;

cout << "Enter invoice layout: ";

cin >> layout;

// Open file

ofstream comp_file;

comp_file.open("Company.txt", ios::out | ios::app);

// Write to file

comp_file << comp_name << " " << comp_address << " " << layout << endl;

// Close file

comp_file.close();

}

// New Customer

void new_customer() {

// Input customer name, address and contact number

string cust_name;

string cust_address;

string contact_no;

cout << "Enter customer name: ";

cin >> cust_name;

cout << "Enter customer address: ";

cin >> cust_address;

cout << "Enter customer contact number: ";

cin >> contact_no;

// Open file

ofstream cust_file;

cust_file.open("Customers.txt", ios::out | ios::app);

// Write to file

cust_file << cust_name << " " << cust_address << " " << contact_no << endl;

// Close file

cust_file.close();

}

// New Order

void new_order() {

// Input order details

string order_no;

string order_date;

string item;

float quantity;

float unit_price;

cout << "Enter order number: ";

cin >> order_no;

cout << "Enter order date: ";

cin >> order_date;

cout << "Enter item: ";

cin >> item;

cout << "Enter quantity: ";

cin >> quantity;

cout << "Enter unit price: ";

cin >> unit_price;

// Open file

ofstream order_file;

order_file.open("Orders.txt", ios::out | ios::app);

// Write to file

order_file << order_no << " " << order_date << " " << item << " " << quantity << " " << unit_price << endl;

// Close file

order_file.close();

}

// Get Item

void get_item() {

// Input item details

string item_no;

string item_name;

float quantity;

float unit_price;

cout << "Enter item number: ";

cin >> item_no;

cout << "Enter item name: ";

cin >> item_name;

cout << "Enter quantity: ";

cin >> quantity;

cout << "Enter unit price: ";

cin >> unit_price;

// Open file

ofstream item_file;

item_file.open("Items.txt", ios::out | ios::app);

// Write to file

item_file << item_no << " " << item_name << " " << quantity << " " << unit_price << endl;

// Close file

item_file.close();

}

// Update Invoice

void update() {

// Input invoice details

float total_amt;

float tax_amt;

float discount;

float advance;

cout << "Enter total amount: ";

cin >> total_amt;

cout << "Enter tax amount: ";

cin >> tax_amt;

cout << "Enter discount: ";

cin >> discount;

cout << "Enter advance: ";

cin >> advance;

// Open file

ofstream inv_file;

inv_file.open("Invoice.txt", ios::out | ios::app);

// Write to file

inv_file << total_amt << " " << tax_amt << " " << discount << " " << advance << endl;

// Close file

inv_file.close();

}

// Print Invoice

void printInv() {

cout << "Invoice Number: " << inv_no << endl;

cout << "Invoice Date: " << inv_date << endl;

cout << "Customer Name: " << cust_name << endl;

cout << "Customer Address: " << cust_address << endl;

cout << "Total Amount: " << total_amt << endl;

cout << "Tax Amount: " << tax_amt << endl;

cout << "Discount: " << discount << endl;

//cout << "Advance: " << advance << endl;

}

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions