======fried rice nutrition calculator======
Made by [[Zoey-lin|Zoey Lin]]
=====essay about the nutrition calculator=====
Everyone must take in enough nutrients every day, but many people may not know whether the nutrients they take every day are enough, so we made a computer about nutrition, which can help us calculate a lot of different nutritional values, such as protein, carbohydrates, fats, iron… And so on for nutritional value. We also incorporate this nutrition computer into our program, so this semester we have a big task to complete a nutrition calculator with the program.
This semester we also spent a lot of time learning how to make a computer, but writing a program is not so simple, and writing a program requires patience, you have to spend a lot of time thinking about how to use and facilitate, and you have to make sure that the answer is correct, so as not to mislead others. Although sometimes I write about being angry, sometimes I always ask the teacher why we are doing this, but through the teacher's continuous efforts and help, we all successfully made our own computers at the end of the semester.
Although the nutrition computer does not sound very difficult, if you want to write a complete nutrition computer program, you need to know a lot of knowledge about mathematics, science, and programs, it takes a lot of time, because it is unlikely to write all right once, it needs to be continuously improved until it is satisfied, we also need to let people quickly understand how to use this nutrition computer, and the answer calculated by the computer should also be easy for people to understand. In this computer, people only need to enter the name of the food they want, and the other 100 grams of nutrients, as long as we enter these computers, we can quickly calculate the nutritional value of this food. So people can quickly know that they have taken in some of the different nutrients today, and they can also quickly improve their diet through this table, and even some people who have lost weight can also use it because he can also help people calculate the calories contained in food.
After this study, I also learned a lot about nutrition, such as how much nutrition people need to take in a day and how each food helps the human body or how to eat to make people healthy, etc., and also learned more new knowledge about procedures, and he also allowed me to know how to be patient and not distracted.
Although we spent a lot of time but finally made something, but the thing made I am quite satisfied, because after all, I spent most of the semester to make it, and I also constantly try to make him better, I hope that this time I made a nutrition computer can, so that others can calculate any nutrients faster.
====關於營養計算器的文章====
每個人每天都必須要攝取足夠的營養,但是可能很多人可能不知道自己每一天攝取的營養是不是足夠的,所以我們就做了一個關於營養的計算機,它可以幫助我們算出很多不同營養價值,像是蛋白質、碳水化合物、脂肪、鐵…等等的營養價值。我們也把這一個營養計算機融入到我們的程式裡面,所以這學期我們有一個很大的任務就是要用程式完成一個營養計算機。
這個學期我們也花了很多的時間在學習如何做一個計算機,但是寫程式其實沒有那麼的簡單,而且寫一個程式需要擁有耐心,你還要花上很多的時間來思考如何才能又好用又方便,你還要確保算出來的答案是正確的,以免誤導別人。雖然有時候會寫到生氣,有時候還會一直問老師說為什麼我們要做這個,但經過老師不斷的努力和幫助下,我們大家也在學期末的時候順利的把自己的計算機都做出來了.
營養計算機雖然聽起來沒有很難,但是如果你想要寫出一個完整的營養計算機程式,你需要知道很多關於數學、科學和程式的知識,還需要花費很多的時間,因為不太可能寫一次就全對,需要不斷的改進直到滿意為止, 我們還需要讓人們可以很快的理解如何使用這一個營養計算機,並且計算機算出來的答案也要讓人們容易理解。在這個計算機裡人們只需要輸入他們要的食物名字,及其他100克的營養成分,只要輸入這些我們的計算機就可以很快就算出來,這個食物的營養價值,所以人們就可以很快地知道說自己今天的攝取了那一些不同的營養素,也可以透過這個表格很快的改善自己的飲食,甚至有一些相減肥的人也可以使用,因為他也可以幫人們計算出食物含有的卡路里。
經過這次學習我也學習到很多關於營養的知識像是人們一天大概要攝取多少營養以及每個食物對人體的幫助或者是怎樣飲食才可以使人健康等等,也學習到更多關於程式的新知識,同時他也讓我能夠比較知道如何保持耐心、不分心。
雖然我們花費很多時間但是最後做出來的東西,但是做出來的東西我還蠻滿意的,因為畢竟是自己花了大半個學期做出來的東西,而且我也不斷地努力想要讓他更好,希望這次我做出來的營養計算機可以,讓其他人更快的能夠算出來任何的營養成分。
class Ingredient {
constructor (name,amountInDish, proteinAmount100g,carbsAmount100g,fatAmount100g,fiberAmount100g,ironAmount100g,sodiumAmount100g,calciumAmount100g,vitaminDAmount100g,caloriesAmount100g,servingSize){
this.name = name;
this.proteinAmount100g = proteinAmount100g;
this.carbsAmount100g = carbsAmount100g;
this.fatAmount100g = fatAmount100g;
this.fiberAmount100g = fiberAmount100g;
//micronutrients
this.ironAmount100g = ironAmount100g;
this.sodiumAmount100g = sodiumAmount100g;
this.calciumAmount100g = calciumAmount100g;
this.vitaminDAmount100g = vitaminDAmount100g;
//calories
this.caloriesAmount100g = caloriesAmount100g;
this.amountInDish = amountInDish;
this.calculatedProtein = undefined;
this.calculatedCarbs = undefined;
this.calculatedFat = undefined;
this.calculatedFiber = undefined;
//micronutrients
this.calculatedIron = undefined;
this.calculatedSodium = undefined;
this.calculatedCalcium = undefined;
this.calculatedVitaminD = undefined;
//calories
this.calculatedCalories = undefined;
this.servingSize = servingSize;
}
}
function calculatedNutrition (IngredientObject) {
//Protein
IngredientObject.calculatedProtein = IngredientObject.proteinAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Carbs
IngredientObject.calculatedCarbs = IngredientObject.carbsAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Fat
IngredientObject.calculatedFat = IngredientObject.fatAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Fiber
IngredientObject.calculatedFiber = IngredientObject.fiberAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Iron
IngredientObject.calculatedIron = IngredientObject.ironAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Sodium
IngredientObject.calculatedSodium = IngredientObject.sodiumAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Calcium
IngredientObject.calculatedCalcium = IngredientObject.calciumAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Vitamin D
IngredientObject.calculatedVitaminD = IngredientObject.vitaminDAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//Calories
IngredientObject.calculatedCalories = IngredientObject.caloriesAmount100g / 100 * IngredientObject.amountInDish/IngredientObject.servingSize;
//haha
IngredientObject.amountInDish = IngredientObject.amountInDish/IngredientObject.servingSize;
food = "fried rice"
return IngredientObject
}
let Ingredients = [
//name,wieght,protein,carbs,fat,fiber,iron,sodium,calcium,vitaminD,calories,servingSize
new Ingredient ('butter',42,0.9,0.1,81,0,0,11,24,0,717,5),
new Ingredient ('eggs',88,13,0.7,9.5,0,1.8,142,56,2,143,5),
new Ingredient ('carrots',120,0.9,9.6,0.2,2.8,0.3,69,33,0,41,5),
new Ingredient ('white onion',125,1.2,9.4,0,1.2,0,0,24,0,41,5),
new Ingredient ('frozen peas',70,5.4,15,0.4,5.7,1.5,5,25,0,81,5),
new Ingredient ('garlic',18,6.4,33,0.5,2.1,1.7,17,181,0,149,5),
new Ingredient ('cooded white rice',744,2.7,28,0.3,0.4,1.2,1,10,0,130,5),
new Ingredient ('green onions',36,0,8,0,4,1.4,40,80,0,40,5),
new Ingredient ('soy sauce',56,8.1,4.9,0.6,0.8,1.5,5493,33,0,53,5),
new Ingredient ('oyster sauce',12,5.5,7.8,8.1,0.2,3.6,242,79,0.6,127,5),
new Ingredient ('sesame oil',2.25,0,0,100,0,0,0,0,0,884,5),
]
Ingredients = Ingredients.map(calculatedNutrition)
function sumArray (inputArray) {
let sum = 0;
for (let i = 0; i < inputArray.length; i++) {
sum = sum + inputArray[i]
}
return sum}
let proteinArray = Ingredients.map(ingredientObject => ingredientObject.calculatedProtein)
let carbsArray = Ingredients.map(ingredientObject => ingredientObject.calculatedCarbs)
let fatArray = Ingredients.map(ingredientObject => ingredientObject.calculatedFat)
let fiberArray = Ingredients.map(ingredientObject => ingredientObject.calculatedFiber)
let ironArray = Ingredients.map(ingredientObject => ingredientObject.calculatedIron)
let sodiumArray = Ingredients.map(ingredientObject => ingredientObject.calculatedSodium)
let calciumArray = Ingredients.map(ingredientObject => ingredientObject.calculatedCalcium)
let vitaminDArray = Ingredients.map(ingredientObject => ingredientObject.calculatedVitaminD)
let caloriesArray = Ingredients.map(ingredientObject => ingredientObject.calculatedCalories)
let weightArray = Ingredients.map(ingredientObject => ingredientObject.amountInDish)
let totalprotein = sumArray (proteinArray)
let totalcarbs = sumArray (carbsArray)
let totalfat = sumArray (fatArray)
let totalfiber = sumArray (fiberArray)
let totaliron = sumArray (ironArray)
let totalsodium = sumArray (sodiumArray)
let totalcalcium = sumArray (calciumArray)
let totalvitaminD = sumArray (vitaminDArray)
let totalcalories = sumArray (caloriesArray)
let totalweight = sumArray (weightArray)
function nutritionPrinter (inputArray, totalAmount,totalAmount2,totalAmount3,totalAmount4,totalAmount5,totalAmount6,totalAmount7,totalAmount8,totalAmount9,totalAmount10) {
inputArray.forEach(ing => {console.log('Nutrition calculator:');
console.log("Ingredient's name: ",ing.name);
console.log("Ingredient's weight ",ing.amountInDish,"g");
//protein
console.log("Protein in",ing.name,": ",ing.calculatedProtein,"g");
//cards
console.log("Carbs in",ing.name,": ",ing.calculatedCarbs,"g");
//fat
console.log("Fat in",ing.name,": ",ing.calculatedFat,"g");
//fiber
console.log("Fiber in",ing.name,": ",ing.calculatedFiber,"g");
//iron
console.log("Micronutrients calculator:");
console.log("Iron in",ing.name,": ",ing.calculatedIron,"mg");
//sodium
console.log("Sodium in",ing.name,": ",ing.calculatedSodium,"mg");
//calcium
console.log("Calcium in",ing.name,": ",ing.calculatedCalcium,"mg");
//vitamin D
console.log("Vitamin D in",ing.name,": ",ing.calculatedVitaminD,"µg");
//calories
console.log("Calories calculator:");
console.log("Calories in",ing.name,": ",ing.calculatedCalories,"calories")
});
console.log('The total amount of',food,'weight: ',totalAmount10,"g");
console.log('The total amount of',food,'protein: ',totalAmount,"g");
console.log('The total amount of',food,'carbs: ',totalAmount2,"g");
console.log('The total amount of',food,'fat: ',totalAmount3,"g");
console.log('The total amount of',food,'fiber: ',totalAmount4,"g");
console.log('Micronutrients total');
console.log('The total amount of',food,'iron: ',totalAmount5,"mg");
console.log('The total amount of',food,'sodium: ',totalAmount6,"mg");
console.log('The total amount of',food,'calcium: ',totalAmount7,"mg");
console.log('The total amount of',food,'vitamin D: ',totalAmount8,"µg");
console.log('Calories total');
console.log('The total amount of',food,'calories: ',totalAmount9,"calories");
}
nutritionPrinter(Ingredients,totalprotein,totalcarbs,totalfat,totalfiber,totaliron,totalsodium,totalcalcium,totalvitaminD,totalcalories,totalweight)
====return====
Nutrition calculator:
VM1178:111 Ingredient's name: butter
VM1178:112 Ingredient's weight 8.4 g
VM1178:114 Protein in butter : 0.07560000000000001 g
VM1178:116 Carbs in butter : 0.008400000000000001 g
VM1178:118 Fat in butter : 6.804 g
VM1178:120 Fiber in butter : 0 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in butter : 0 mg
VM1178:125 Sodium in butter : 0.924 mg
VM1178:127 Calcium in butter : 2.016 mg
VM1178:129 Vitamin D in butter : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in butter : 60.227999999999994 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: eggs
VM1178:112 Ingredient's weight 17.6 g
VM1178:114 Protein in eggs : 2.2880000000000003 g
VM1178:116 Carbs in eggs : 0.12319999999999998 g
VM1178:118 Fat in eggs : 1.672 g
VM1178:120 Fiber in eggs : 0 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in eggs : 0.3168 mg
VM1178:125 Sodium in eggs : 24.991999999999997 mg
VM1178:127 Calcium in eggs : 9.856 mg
VM1178:129 Vitamin D in eggs : 0.352 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in eggs : 25.168 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: carrots
VM1178:112 Ingredient's weight 24 g
VM1178:114 Protein in carrots : 0.21600000000000003 g
VM1178:116 Carbs in carrots : 2.304 g
VM1178:118 Fat in carrots : 0.048 g
VM1178:120 Fiber in carrots : 0.6719999999999999 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in carrots : 0.072 mg
VM1178:125 Sodium in carrots : 16.56 mg
VM1178:127 Calcium in carrots : 7.92 mg
VM1178:129 Vitamin D in carrots : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in carrots : 9.84 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: white onion
VM1178:112 Ingredient's weight 25 g
VM1178:114 Protein in white onion : 0.3 g
VM1178:116 Carbs in white onion : 2.35 g
VM1178:118 Fat in white onion : 0 g
VM1178:120 Fiber in white onion : 0.3 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in white onion : 0 mg
VM1178:125 Sodium in white onion : 0 mg
VM1178:127 Calcium in white onion : 6 mg
VM1178:129 Vitamin D in white onion : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in white onion : 10.25 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: frozen peas
VM1178:112 Ingredient's weight 14 g
VM1178:114 Protein in frozen peas : 0.756 g
VM1178:116 Carbs in frozen peas : 2.1 g
VM1178:118 Fat in frozen peas : 0.05600000000000001 g
VM1178:120 Fiber in frozen peas : 0.798 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in frozen peas : 0.21000000000000002 mg
VM1178:125 Sodium in frozen peas : 0.7 mg
VM1178:127 Calcium in frozen peas : 3.5 mg
VM1178:129 Vitamin D in frozen peas : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in frozen peas : 11.34 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: garlic
VM1178:112 Ingredient's weight 3.6 g
VM1178:114 Protein in garlic : 0.23040000000000002 g
VM1178:116 Carbs in garlic : 1.1880000000000002 g
VM1178:118 Fat in garlic : 0.018 g
VM1178:120 Fiber in garlic : 0.0756 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in garlic : 0.06120000000000001 mg
VM1178:125 Sodium in garlic : 0.612 mg
VM1178:127 Calcium in garlic : 6.516 mg
VM1178:129 Vitamin D in garlic : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in garlic : 5.364 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: cooded white rice
VM1178:112 Ingredient's weight 148.8 g
VM1178:114 Protein in cooded white rice : 4.0176 g
VM1178:116 Carbs in cooded white rice : 41.664 g
VM1178:118 Fat in cooded white rice : 0.4464 g
VM1178:120 Fiber in cooded white rice : 0.5952 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in cooded white rice : 1.7856 mg
VM1178:125 Sodium in cooded white rice : 1.488 mg
VM1178:127 Calcium in cooded white rice : 14.88 mg
VM1178:129 Vitamin D in cooded white rice : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in cooded white rice : 193.44 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: green onions
VM1178:112 Ingredient's weight 7.2 g
VM1178:114 Protein in green onions : 0 g
VM1178:116 Carbs in green onions : 0.576 g
VM1178:118 Fat in green onions : 0 g
VM1178:120 Fiber in green onions : 0.288 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in green onions : 0.1008 mg
VM1178:125 Sodium in green onions : 2.88 mg
VM1178:127 Calcium in green onions : 5.76 mg
VM1178:129 Vitamin D in green onions : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in green onions : 2.88 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: soy sauce
VM1178:112 Ingredient's weight 11.2 g
VM1178:114 Protein in soy sauce : 0.9072000000000001 g
VM1178:116 Carbs in soy sauce : 0.5488000000000001 g
VM1178:118 Fat in soy sauce : 0.06720000000000001 g
VM1178:120 Fiber in soy sauce : 0.0896 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in soy sauce : 0.16799999999999998 mg
VM1178:125 Sodium in soy sauce : 615.216 mg
VM1178:127 Calcium in soy sauce : 3.696 mg
VM1178:129 Vitamin D in soy sauce : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in soy sauce : 5.936 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: oyster sauce
VM1178:112 Ingredient's weight 2.4 g
VM1178:114 Protein in oyster sauce : 0.132 g
VM1178:116 Carbs in oyster sauce : 0.18719999999999998 g
VM1178:118 Fat in oyster sauce : 0.1944 g
VM1178:120 Fiber in oyster sauce : 0.0048000000000000004 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in oyster sauce : 0.0864 mg
VM1178:125 Sodium in oyster sauce : 5.808 mg
VM1178:127 Calcium in oyster sauce : 1.8960000000000001 mg
VM1178:129 Vitamin D in oyster sauce : 0.014400000000000001 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in oyster sauce : 3.048 calories
VM1178:110 Nutrition calculator:
VM1178:111 Ingredient's name: sesame oil
VM1178:112 Ingredient's weight 0.45 g
VM1178:114 Protein in sesame oil : 0 g
VM1178:116 Carbs in sesame oil : 0 g
VM1178:118 Fat in sesame oil : 0.45 g
VM1178:120 Fiber in sesame oil : 0 g
VM1178:122 Micronutrients calculator:
VM1178:123 Iron in sesame oil : 0 mg
VM1178:125 Sodium in sesame oil : 0 mg
VM1178:127 Calcium in sesame oil : 0 mg
VM1178:129 Vitamin D in sesame oil : 0 µg
VM1178:131 Calories calculator:
VM1178:132 Calories in sesame oil : 3.978 calories
VM1178:134 The total amount of fried rice weight: 262.65 g
VM1178:135 The total amount of fried rice protein: 8.922799999999999 g
VM1178:136 The total amount of fried rice carbs: 51.0496 g
VM1178:137 The total amount of fried rice fat: 9.756 g
VM1178:138 The total amount of fried rice fiber: 2.8232 g
VM1178:139 Micronutrients total
VM1178:140 The total amount of fried rice iron: 2.8008 mg
VM1178:141 The total amount of fried rice sodium: 669.1800000000001 mg
VM1178:142 The total amount of fried rice calcium: 62.04 mg
VM1178:143 The total amount of fried rice vitamin D: 0.3664 µg
VM1178:144 Calories total
VM1178:145 The total amount of fried rice calories: 331.472 calories
undefined
Back To [[zoey-lin#artwork_research_writng_and_other_work|Zoey Lin's assignment page.]]