Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Theory Icdt 97 6th International Conference Delphi Greece January 8 10 1997 Proceedings Lncs 1186

Authors: Foto N. Afrati ,Phokion G. Kolaitis

1st Edition

3540622225, 978-3540622222

More Books

Students also viewed these Databases questions

Question

=+22-1 Describe the place of consciousness in psychology's history.

Answered: 1 week ago

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago

Question

Explain strong and weak atoms with examples.

Answered: 1 week ago

Question

Explain the alkaline nature of aqueous solution of making soda.

Answered: 1 week ago