Question: this program is created in C ++ , ... update it by using classes And .. in the update function after make it update selected

this program is created in C ++ , ... update it by using classes

And .. in the update function after make it update selected invoice from the file .

#include #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();

int main() { //Main Menu main_menu();

return 0; }

//Main Menu void main_menu() { //Variables int choice;

//Display Main Menu cout << "Choose an option please:" << endl; cout << "1. Create a New Invoice" << endl; cout << "2. add a New Company" << endl; cout << "3.add New Customer" << endl; cout << "4. place a New Order" << endl; cout << "5. Others" << endl; cout << "6. Exit" << endl;

//Input choice cin >> choice;

//Switch statement switch (choice) { case 1: new_invoice(); break;

case 2: new_company(); break;

case 3: new_customer(); break;

case 4: new_order(); break;

case 5: //Other sub-menu cout << "1. Get Item" << endl; cout << "2. Update" << endl; cout << "3. Print" << endl;

//Input choice cin >> choice;

//Switch statement switch (choice) { case 1: get_item(); break;

case 2: update(); break;

case 3: print(); break; } break;

case 6: //Exit exit(0); break; } }

//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();

//Return to main menu main_menu(); }

//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();

//Return to main menu main_menu(); }

//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();

//Return to main menu main_menu(); }

//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();

//Return to main menu main_menu(); }

//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();

//Return to main menu main_menu(); }

//Update void update() { //Input invoice details float total_amt; float tax_amt; float discount; float advance;

cout << "Enter total amount of invoice: "; 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();

//Return to main menu main_menu(); }

//Print void print() { //Print invoice 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: " << setw(10)<< discount << endl;

//Return to main menu main_menu(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!