Sunday, July 10, 2016

Product Total Cost in C++

A simple program that I wrote in C++ that will compute the product total cost. I used this program as an example in my programming class in college before I work in the industry as software engineer. I hope you will find my work useful.


Add me at Facebook my address  is 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;


struct item {

    string name,type;
    int quantity;
    float price;
};

main() {
     item product;
     float solve=0.00;
     cout << "\n\tProduct Total Cost 1.0";
     cout << "\n\n";
     cout << "Enter Product Name         : ";
     getline(cin,product.name);
     cout << "Enter Product Description  : ";
     getline(cin,product.type);
     cout << "Enter Product Quantity     : ";
     cin >> product.quantity;
     cout << "Enter Product Price/Pcs    : ";
     cin >> product.price;

     solve = (product.quantity * product.price);

     cout << fixed << setprecision(2);

     cout << "\n  === Report ===";
     cout << "\n\n";
     cout << "\nProduct Name   : " << product.name;
     cout << "\nProduct Type   : " << product.type;
     cout << "\nQuantity       : " << product.quantity;
     cout << "\nPrice          : " << product.price;
     cout << "\n\n Total Cost  : $ " << solve;
     cout << "\n\n";
     system("pause");
}


No comments:

Post a Comment