class diagram is correct or not...If the class diagram is correct please give the short explanation for each box. And if the class diagram is not correct then please make the correct class diagram and give the explanation for each box as well..
Based on that code can u please check the given class diagram is correct or not...If the class diagram is correct please give the short explanation for each box. And if the class diagram is not correct then please make the correct class diagram and give the explanation for each box as well...
code:
#include <iostream>
#include <string>
using namespace std;
class Product{
public:
string name;
double price;
Product(string m_name, double m_price)
{
name = m_name;
price = m_price;
}
};
void printLine()
{
for(int i = 0; i<60; i++)
cout << "_";
cout << endl << endl;
}
int main()
{
Product *arr[4];
arr[0] = new Product("A", 10);
arr[1] = new Product("B", 20);
arr[2] = new Product("C", 30);
arr[3] = new Product("D", 40);
int uid;
string name, address, state;
int pno, poscode;
double shipping;
cout << "\t\t\tWELCOME" << endl;
printLine();
cout << "\t\tEnter User Id: ";
cin >> uid;
char ch = 'Y';
do
{
system("clear");
cout << "\t\t\tCUSTOMER DETAIL" << endl;
printLine();
cout << "\tNAME | ";
cin.ignore();
getline(cin, name);
cout << "\tPHONE NUMBER | ";
cin >> pno;
cout << "\tADDRESS | ";
cin.ignore();
getline(cin, address);
cout << "\tPOSCODE | ";
cin >> poscode;
cout << "\tSTATE | ";
cin.ignore();
getline(cin, state);
cout << "\tSHIPPING COST | ";
cin >> shipping;
cout << endl << endl;
cout << "\tProceed to Product Detail?" << endl << "\t(Y) YES" << endl << "\t(N) RESET" << endl;
cout << "\tChoice | ";
cin >> ch;
}while(ch != 'Y');
system("clear");
ch = 'Y';
int count = 0;
char products[100];
int quantity[100];
int discount;
do
{
system("clear");
cout << "\t\t\tPRODUCT DETAIL" << endl;
printLine();
for(int i = 0; i < 4; i++)
{
cout << "\t" << '(' << (char)('A' + i) << ") |PRODUCT " << arr[i]->name
<< " ------ RM " << arr[i]->price << " |" << endl;
}
cout << endl << endl << "\t|DISCOUNT CODE:" << endl;
cout << "\t[disc50\%]" << endl << "\t[disc25\%]" << endl;
char choice = '0';
count = 0;
do
{
cout << endl << " INSERT PRODUCT ";
if(choice != '0')
{
cout << "(IF NO PRESS \'0\') ";
}
cout << "| ";
cin >> choice;
if(choice == '0')
break;
cout << " INSERT QUANTITY | ";
cin >> quantity[count];
products[count] = choice;
count++;
} while(choice != '0');
cout << endl << " DISCOUNT CODE | ";
cin >> discount;
cout << endl;
cout << " Proceed to Billing?" << endl << " (Y) YES" << endl << " (N) RESET" << endl;
cout << " Choice | ";
cin >> ch;
}while(ch != 'Y');
system("clear");
cout << "\t\t\tRECEIPT" << endl;
printLine();
cout << " " << name << "\n " << pno << "\n "
<< address << "\n " << poscode << "\n "
<< state << endl << endl;
double total = 0;
for(int i = 0; i < count; i++)
{
cout << " Product " << products[i] << " Qty-" << quantity[i] << endl;
total = total + (arr[products[i] - 'A']->price * quantity[i]);
}
cout << " Amount - RM" << total << endl;
cout << " Discount " << discount << "\%" << endl;
cout << " Shipping - RM" << shipping << endl;
total = (total * discount) / 100.0 + shipping;
cout << " Total - RM" << total << endl << endl;
cout << " PIC - " << uid << endl << endl;
cout << "\t\tTHANK YOU FOR SHOPPING WITH US !" << endl;
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images