Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- //requirement #1.
- //initial integers.
- float depth = 0,
- width = 0,
- heigth = 0;
- float area1 = 0,
- area2 = 0,
- combined_area = 0;
- double total_price = 0;
- char compute;
- //initial input.
- while (true)
- {
- cout << "=====================" << endl;
- cout << "GLASS SHOWER ESTIMATE" << endl;
- cout << "=====================" << endl;
- //enter the depth, width, heigth.
- cout << "Depth: ";
- cin >> depth;
- cout << "Width: ";
- cin >> width;
- cout << "Heigth: ";
- cin >> heigth;
- //measure the areas.
- area1 = depth * heigth;
- area2 = width * heigth;
- combined_area = area1 + area2;
- //requirement #2.
- float price_unit;
- if (combined_area >= 6000)
- {
- price_unit = .99;
- cout << "Unit Price: " << price_unit << endl;
- total_price += price_unit * combined_area;
- //cout<<combined_area;
- }
- else if (combined_area >= 3000)
- {
- price_unit = 1.29;
- cout << "Unit Price: " << price_unit << endl;
- total_price += price_unit * combined_area;
- //cout<<combined_area;
- }
- else
- {
- price_unit = 1.49;
- cout << "Unit Price: " << price_unit << endl;
- total_price += price_unit * combined_area;
- }
- //requirement #3.
- //thickness of glass.
- float thickness;
- float surcharge;
- cout << "Thickness: ";
- cin >> thickness;
- if (thickness >= .5)
- {
- surcharge = .5;
- //checking the surcharge.
- cout << surcharge * 100 << "%" << " for " << surcharge << " thickness." << endl;
- total_price += surcharge * total_price;
- }
- else if (thickness >= .375)
- {
- surcharge = .20;
- cout << surcharge * 100 << "%" << " for " << surcharge << " thickness." << endl;
- total_price += surcharge * total_price;
- }
- //requirement #4.
- //using code to find possible discount.
- double discount_code;
- float discount;
- cout << "Discount Code (enter 0 if no code): ";
- cin >> discount_code;
- if (discount_code == 112233)
- {
- discount = .20 * total_price;
- //checking discount given.
- cout << "20% Discount applied." << endl;
- total_price = total_price - discount;
- }
- else if (discount_code == 111222)
- {
- discount = .10 * total_price;
- cout << "10% Discount applied." << endl;
- total_price = total_price - discount;
- }
- else if (discount_code == 0)
- {
- cout << "There's no discount" << endl;
- //gotta recheck this output.
- }
- else
- {
- cout << "Invalid Discount Code!" << endl;
- }
- //requirement #5.
- //output will be shown
- //and the program will ask the user if he wants to
- //add another number.
- cout << "The installed price is $ " << total_price << endl;
- cout << "Would you like to compute another one? (y/n)";
- cin >> compute;
- if (compute == 'y' || compute == 'Y')
- {
- depth = 0,
- width = 0,
- heigth = 0;
- area1 = 0,
- area2 = 0,
- combined_area = 0;
- total_price = 0;
- cout << " " << endl;
- }
- else
- {
- break;
- }
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement