C++ Register Program
//define iostream.h to read to or from the screen
#include <iostream.h>
//bill class
class bill
{
//private variables
private:
float sum_product;
float total_tax;
float total_bill;
float item1;
float item2;
float item3;
//public variables
public:
//constructor
bill(float p, float t):
sum_product(p),
total_tax(t),
total_bill(p + t) {}
//welcomeMessage
void welcomeMessage()
{
cout<<endl<<"WELCOME!"<<endl<<endl;
}
//initializeProduct
void initializeProduct(float it1, float it2, float it3)
{
item1= it1;
item2= it2;
item3= it3;
}
//printProduct
void printProduct()
{
cout<<"item1 $"<<item1<<endl;
cout<<"item2 $"<<item2<<endl;
cout<<"item3 $"<<item3<<endl;
}
//sumProduct
void sumProduct()
{
sum_product = item1 + item2 + item3;
cout<<"-------------------------------"<<endl;
cout<<"Total Product Value: $"<<sum_product<<endl;
}
//totalTax
void totalTax()
{
float PST = .06;
float GST = .07;
total_tax = (sum_product * PST) +(sum_product * GST);
cout<<"Total Tax Value: $"<<total_tax<<endl;
}
//totalBill
void totalBill()
{
total_bill = sum_product + total_tax;
cout<<"-------------------------------"<<endl;
cout<<"Amount Owed: $"<<total_bill<<endl;
}
//byeMessage
void byeMessage()
{
cout<<endl<<"THANK-YOU, COME AGAIN!"<<endl<<endl;
}
};
//main class
void main()
{
bill billObject(0, 0);
billObject.welcomeMessage();
billObject.initializeProduct(1.23, 3.05, 2.15);
//desired format was to have the items listed then their total sum
billObject.printProduct();
billObject.sumProduct();
billObject.totalTax();
billObject.totalBill();
billObject.byeMessage();
}