Comparison of bread types at the Ströck bakery

For more information, visit Ströck bakery

#include <iostream> #include <vector> #include <map> #include <cmath> using namespace std; struct Bread { int weight_g; // quantity in 100g weight float energy_kJ; float energy_kcal; float protein_g; float carbohydrates_g; float sugar_g; float fat_g; float saturated_fats_g; float ballast_substances_g; float salt_g; float BE; }; int main() { map<string, Bread> breads = { {"Baguette", Bread{300,1015,240,8.1,46.3,1.6,1.9,0.1,2.4,1.46,3.9}}, {"Bauernlaib", Bread{3000,969,231,6.5,44,3.3,1.9,0.5,5,1.63,3.7}}, {"Bio-Almlaib", Bread{500,1064,254,6.6,48.9,0.8,1,0.2, 6.2,1.65,4.1}}, {"Bio-Bagett", Bread{300,994,234,7,49.1,0.5,0.7,0.1,1.9,1.53,4.1}}, {"Bio-Bergsteiger", Bread{1600,1100,263,9.4,40.9,1.2,5.7,0.9,5.3,1.4,3.4}}, {"Bio-Dinkelbrot", Bread{500,1143,271,10.3,44.1,1,4.8,0.7,5.1,1.5,3.7}}, {"Bio-Feierabend-Bauernciabatta", Bread{350,1017,241,11.5,36.3,1.8,3.8,0.6,1.14,3}}, {"Bio-Feierabend-Christoph-Brot", Bread{500,905,213,7.9,42.4,0.4,0.7,0.1,2.7,2.15,3.5}}, {"Bio-Feierabend-Laurenzio-Wecken", Bread{1000,859,202,5.9,43,0,0.6,0.3,1.6,1.6,3.6}}, {"Bio-Feierabend-Walnusskrone", Bread{800,1224,291,9.1,39.8,1.1,10,1,3,1.97,3.3}}, {"Bio-Frankenbrot", Bread{750,1073,256,8.1,49.7,3.2,1.2,0.2,5.3,1.6,4.1}}, {"Bio-Frauenbrot", Bread{500,956,227,0.4,34.6,1.1,4.2,0.5,8.2,1.54,2.9}}, {"Bio-Kornbaguette", Bread{300,928,220,8,36.1,1,4,0.4,3.8,1.1,3}}, {"Bio-Landbrot", Bread{1800,852,201,6,40.1,0.5,1.3,0.2,2.4,1.33,3.3}}, {"Bio-Roggen-Pur", Bread{700,1036,245,5.3,51.9,0.2,0.9,0.2,3.8,2,4.3}}, {"Bio-Roggen-Sauerteigbrot", Bread{1000,908.3,216.8,4.8,46.4,0.8,1,0.1,9.6,1.5,3.7}}, {"Bio-Roggenvollkorn-Eck", Bread{1000,989,236,6.4,44.4,0.7,1.2,0.2,9.6,1.6,3.7}}, {"Bio-Sonnenblumenbrot", Bread{750,1063,253,7.7,37.5,1.2,6.6,0.8,5.9,1.33,3.1}}, {"Bio-Vollkornbrot", Bread{750,1078,257,6.8,49,0.8,1.2,0.2,0.3,1.66,4.1}}, {"Dachsteinbrot", Bread{750,1095,262,9.2,36.2,2.6,7.3,0.8,6.8,2,3}}, {"Feierabend-Nuss-Früchtebrot", Bread{600,1302,310,9.7,40.1,8.7,10.6,1.4,6.5,1.12,3.3}}, {"Feierabend-Roggen-Buchweizenbrot", Bread{500,768,182,4.1,36.1,4,1.4,0.2,4,1.7,3}}, {"Finnenbrot", Bread{1200,1152,275,10.1,34.6,1.7,0.4,1,9.6,0.9,2.9}}, {"Gersten-Dinkelbrot", Bread{500,945,224,7.4,34.1,2.2,5.2,0.6,5.8,1.18,2.9}}, {"Kärntnerbrot", Bread{1600,1074,254,7,50.4,0.9,1.2,0.2,6.7,1.6,4.2}}, {"Kürbiskernbrot", Bread{750,1037,248,10,38,2.1,4.7,1.5,5.8,1.48,3.2}}, {"Mischbrot 1000g", Bread{1000,907,217,6.3,42.6,2.8,1,0.8,4.6,1.53,3.6}}, {"Mischbrot 500g", Bread{500,907,217,6.3,42.6,2.8,1,0.8,4.6,1.53,3.6}}, {"Nussbrot", Bread{500,1145,272,0.4,41,2.5,7.6,0.9,4,1.3,3.4}}, {"Olivenbrot", Bread{500,1117,265,7.7,43.8,1.6,5.8,1.5,2.7,2.01,3.7}}, {"Pain Provençal", Bread{500,1083,259,9.7,50.7,0.8,0.9,0.1,3.1,1.92,4.2}}, {"Roggenbrot 1000g", Bread{1000,1011,241,7.5,46.9,3.2,1.2,0.2,5,1.68,3.9}}, {"Roggenbrot 500g", Bread{500,1011,241,7.5,46.9,3.2,1.2,0.2,5,1.68,3.9}}, {"Sandwich", Bread{500,1165,277,0.6,55.3,1,1.5,0.4,2.8,1.4,4.2}}, {"Schweizerbrot", Bread{1000,1069,253,7.5,47.7,1.8,3,1.3,2.5,1.39,4}}, {"SonnenVit-Brot", Bread{400,1095,262,9,24.5,1.1,12.1,1.5,1.27,NULL}}, {"Toastbrot", Bread{500,1311,313,9.1,58.1,3.5,3.9,1.6,2.9,1.2,4.8}}, {"Zwiebelbrot", Bread{500,1135,271,7.3,45.7,4.1,5.2,2.1,4.7,1.51,3.8}} }; // Does "Bio-bagett" feed better or worse than "Baguette"? If so, by how many kcal/100g? float kcal_diff = breads["Bio-Bagett"].energy_kcal - breads["Baguette"].energy_kcal; cout << (kcal_diff > 0 ? "better":"worse") << endl << "by " << abs(kcal_diff) << " kcal" << endl; // worse, by 6 kcal // Is there a bread which can feed a group of six at a picnic, provided they eat 300g on average? int party_serving_g = 6*300; for(auto bread : breads) { if(bread.second.weight_g >= party_serving_g) { cout << bread.first << endl; } } // Bauernlaib // Bio-Landbrot // Which bread has most protein, least fats and most BE? string bread_name; vector<float> quantities_g = {0,9999,0}; for(auto bread : breads) { Bread br = bread.second; if( br.protein_g > quantities_g[0] && br.fat_g < quantities_g[1] && br.BE > quantities_g[2] ) { quantities_g[0] = br.protein_g; quantities_g[1] = br.fat_g; quantities_g[2] = br.BE; bread_name = bread.first; } cout << br.protein_g << " " << br.fat_g << " " << br.BE << endl; } cout << bread_name << endl; cout << "Protein: " << quantities_g[0] << "g, Fat: " << quantities_g[1] << "g, BE: " << quantities_g[2] << endl; // Pain Provençal // Protein: 9.7g, Fat: 0.9g, BE: 4.2 // For instance, Finnenbrot has (10.1, 0.4, 2.9) (better on the first two, but not the last criteria) return 0; }