Saturday, January 9, 2016

Total Product Cost Solver in C++

This sample program will compute for the total cost of products purchase in a grocery store using C++ as our programming language.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <iomanip>

using namespace std;

main() {

    string products[50];
    int values=0;
    float item_price[50];
    int total_cost=0,paid=0;
    float tax = 0.12,solve=0.00,tax_solve=0.00;
    float final_cost=0.00;
    cout << "\n\t\t ABC Grocery Store";
    cout << "\n\n";
    cout << "How many items : ";
    cin >> values;
     for (int x=1; x<=values; x++)
       {
           cout << setprecision(2) << fixed;
           cout << "\n\n";
           cout << "Item Name  : ";
           cin >> products[x];
           cout << "Item Price : ";
           cin >> item_price[x];
           total_cost+= item_price[x];
           cout << "\n";
           cout << "Sub-Total Cost $ " << total_cost;

       }
      cout << "\n\n";

       tax_solve = ( total_cost * tax);
        final_cost = (total_cost + tax_solve);
      cout << setprecision(2) << fixed;
      cout << "\nVAT 12%     $ " <<tax_solve;
       cout << "\nTotal Cost $ " << final_cost;
       cout << "\n";
       cout << "\nEnter  amount Paid  $ ";
      cin >> paid;
      solve = (paid - final_cost);
      cout << "\n\n";
      cout << "Amount Change $ " << solve;

     cout << "\n\n";
     system("pause");
}

No comments:

Post a Comment