#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int main()
{
   const int LENGTH = 100;
   vector<double> prices;

   double price;
   while (cin >> price)
   {
      if (prices.size() < LENGTH)
      {
         prices.push_back(price);
      }
   }

   double sum = 0.0;

   if (prices.size() >= 2)
   {
       sum = prices[0] + prices[prices.size() - 1];
   }
   else if (prices.size() == 1)
   {
       sum = prices[0];
   }

   for (const auto& element : prices) {
        std::cout << element << " " << "\n";
   }
   cout << fixed << setprecision(2);
   const std::string BOLD_ON = "\033[1m";


   cout << BOLD_ON << "Sum of first and last: " <<  sum << endl;

   return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: