1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void newLine();
double total(double, double, double, int, int, int);
struct customer
{
string contactNo;
struct {
string lastName;
string firstName;
}name;
struct {
struct {
string day, month, year;
}date;
struct{
string ID;
string name;
double price;
int quantity;
}item[3];
}order;
};
int sum;
int main()
{
customer cust[3];
cout << "Enter 3 customers: " << "\n" << "\n";
for (int i = 0; i < 3; i++)
{
cout << "CUSTOMER INFORMATION " << i + 1 << "\n";
cout << "First Name: ";
cin >> cust[i].name.firstName;
newLine();
cout << "Last Name: ";
getline(cin, cust[i].name.lastName);
cout << "Contact No: ";
cin >> cust[i].contactNo;
cout << "Order Date:\n";
cout << "Day: ";
cin >> cust[i].order.date.day;
cout << "Month: ";
cin >> cust[i].order.date.month;
cout << "Year: ";
cin >> cust[i].order.date.year;
cout << "Enter 3 items: " << "\n";
for (int j = 0; j < 3; j++)
{
cout << "ID: ";
cin >> cust[i].order.item[j].ID;
cout << "Name: ";
cin >> cust[i].order.item[j].name;
cout << "Price: ";
cin >> cust[i].order.item[j].price;
cout << "Quantity: ";
cin >> cust[i].order.item[j].quantity;
}
system("cls");
}
cout << "SUMMARY REPORT\n";
cout << setw(5) << "#"
<< setw(20) << "Customer Name "
<< setw(20) << "Order Date "
<< setw(10) << "Items"
<< setw(10) << "Price"
<< setw(16) << "Quantity\n";
for (int i = 0; i < 3; i++)
{
cout << setw(5) << i + 1
<< setw(15) << cust[i].name.lastName << ", " << cust[i].name.firstName
<< setw(15) << cust[i].order.date.month << "/" << cust[i].order.date.day << "/" << cust[i].order.date.year << "\n";
for (int j = 0; j < 3; j++)
{
cout << setw(55) << cust[i].order.item[j].name
<< setw(10) << cust[i].order.item[j].price
<< setw(10) << cust[i].order.item[j].quantity;
cout << "\n";
}
cout.setf(ios::fixed);
cout.precision(2);
cout << setw(70) << "TOTAL PRICE: " << total(cust[i].order.item[0].price, cust[i].order.item[1].price, cust[i].order.item[2].price,
cust[i].order.item[0].quantity, cust[i].order.item[1].quantity, cust[i].order.item[2].quantity) << "\n";
}
system("pause>0");
return 0;
}
double total(double p1, double p2, double p3, int q1, int q2, int q3)
{
double sum = ((p1*q1) + (p2*q2) + (p3*q3));
return sum;
}
void newLine()
{
char s; do{
cin.get(s);
} while (s != '\n');
}
|