Instructions
Requirements and Specifications
Source Code
#include
#include
#include
using namespace std;
int main()
{
double solarPanelPrice = 500.00;
double generatorPrice = 7500.00;
double salesTaxRate = 0.075;
double financeCharge = 0.15;
double discountPer = 0.10;
int numSolarPanelPurchase;
int numGeneratorPurchase;
string companyName;
double subtotal, tax, fee, discount, avgPriceWithCash, avgPriceWithFinance;
double totalCostSolarPanels, totalCostGenerators, tempTotal, total;
cout << "\n" << fixed << setprecision(2);
cout << "\n" << "Enter the name of the company ";
getline(cin, companyName);
cout << "\n" << "Enter the number of generators to purchase ";
cin >> numGeneratorPurchase;
cout << "\n" << "Enter the number of solar panels to purchase ";
cin >> numSolarPanelPurchase;
totalCostGenerators = generatorPrice * numGeneratorPurchase;
totalCostSolarPanels = numSolarPanelPurchase * solarPanelPrice;
subtotal = totalCostSolarPanels + totalCostGenerators;
discount = subtotal * discountPer;
fee = subtotal * financeCharge;
cout << "\n" << "Invoice for " << companyName << "\n" << "\n";
cout << "Cost for " << numGeneratorPurchase << " generators is $" << totalCostGenerators << "\n";
cout << "Cost for " << numSolarPanelPurchase << " solar panels is $" << totalCostSolarPanels << "\n";
tempTotal = subtotal - discount;
cout << "\n" << "If paying cash for the purchase" << "\n";
cout << "The subtotal is $" << tempTotal << "\n";
cout << "The discount is $" << discount << "\n";
tax = tempTotal * salesTaxRate;
total = tempTotal + tax;
cout << "Tax is $" << tax << "\n";
cout << "The total bill is $" << total << "\n";
avgPriceWithCash = total / (numSolarPanelPurchase + static_cast (numGeneratorPurchase));
cout << "The average cost of the equipment is $" << avgPriceWithCash << "\n" << "\n";
tempTotal = subtotal + fee;
cout << "\n" << "If financing the purchase" << "\n";
cout << "The subtotal is $" << tempTotal << "\n";
cout << "The discount is $" << fee << "\n";
tax = tempTotal * salesTaxRate;
total = tempTotal + tax;
cout << "Tax is $" << tax << "\n";
cout << "The total bill is $" << total << "\n";
avgPriceWithFinance = total / (numSolarPanelPurchase + static_cast (numGeneratorPurchase));
cout << "The average cost of the equipment is $" << avgPriceWithFinance << "\n" << "\n";
cout << "By paying cash you would save $" << (avgPriceWithFinance - avgPriceWithCash) << " per piece of equipment" << "\n" << "\n";
return 0;
}