Create a new C empty project titled CS115IP4YourName in the

Create a new C++ empty project titled \"CS115_IP4_YourName\" in the IDE. Use 2 arrays: one for the products, and one for the quantities. Use loops to assign values to the arrays. Use loops to read and print values from the arrays. Reuse the functions that you developed in Week 2 and the customer class that you developed in Week 3. Changes can be done as needed. Complete the following in your code: Provide a list of available products Ask the customer to select products and quantities Save the provided details in arrays Read from the arrays to print the order summary; that is, the products, quantities, and the total price for each product Calculate and print the total price for the order. I need help writing this program can some one help me. I\'m using dev c and i need it in english. Create a new C++ empty project titled \"CS115_IP3_YourName\" in the IDE. Design the customer class. Include at least the customer name and address for the class. Create class functions to set the class variables. Create class functions to get the values of the class variables. Create additional functions as necessary. Complete the following in your code: Implement the new class Create an object from the new class Set the customer details using the class functions Use the class functions to access the customer details Create a new C++ empty project titled \"CS115_IP2_YourName\" in the IDE. Determine the functions that you need to create (you need at least 3). Design and implement those functions in the IDE. Your program should provide the following additional functionality (in addition to the functionality provided in Week1): Ask customers to select multiple products and quantities Print the order summary, including the products, the quantities, and the total price for each product Calculate and print the total price for the order Compile and run the application to demonstrate a working program

Solution


#include <string>
#include <iostream>

using namespace std;

//declaration of class
class Customer {
  
// members are private by default
      string c_name;                  
      string c_address;

// you explicitly declare the public section
   public:
       Customer();
       void setName(string n);
       void setAddress(string a);
       string getName();
       string getAddress();
};

Customer:: Customer() {              // constructor        
    c_name = \"\";        
    c_address = \"\";
}   

void Customer::setName(string n) {
    c_name = n;
}

void Customer::setAddress(string a) {
    c_address = a;
}

string Customer::getName( ) {
    return c_name;
}

string Customer::getAddress( ) {
    return c_address;
  
}
//declaration of structure
struct Product {
  
    string p_name;
    double price;
    float quantity;
};

    int main() {
    Customer c1;
    int p,order = 0;
    string c_name, c_address;
    cout << \"Please enter number of products\" <<endl;
    cin >> p;
    Product *products = new Product[p]; //stucture array
    for(int i=0; i<p; i++){
        cout << \"Please enter product name\" <<endl;
        cin >> products[i].p_name;
        cout << \"Please enter product price\" <<endl;
        cin >> products[i].price;
        cout << \"Please enter product quantity\" <<endl;
        cin >> products[i].quantity;
        order += (products[i].price * products[i].quantity) ;
    }
  
    cout << \"Please enter customer\'s name \" << endl;
    cin >> c_name;
    c1.setName(c_name);       
    cout << \"Please enter customer\'s address \" << endl;   
    cin >> c_address;    
    c1.setAddress(c_address);
    cout << \"Name: \" << c1.getName();   
    cout << \"Address: \" << c1.getAddress();
    cout <<\"Total Order Value: \"<< order << endl; // Display the result
    return 0;
}

Create a new C++ empty project titled \
Create a new C++ empty project titled \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site