Arvutiteaduse instituut
  1. Kursused
  2. 2020/21 sügis
  3. Programmeerimise alused II (MTAT.03.256)
EN
Logi sisse

Programmeerimise alused II 2020/21 sügis

  • Home
  • Grading
  • Links

Homework 1

The deadline is Sunday, the 15th of November, 23:59 (Estonian time).

The caloric value of food shows how much energy your body gets from the carbohydrates, proteins and fats that the food contains. The file calories.txt contains different meals on separate lines. The number of carbohydrates, proteins and fats is given for each meal in grams. It is known that

  • 1 g of carbohydrate gives 4 Kcal,
  • 1 g of protein gives 4 Kcal,
  • 1 g of fat gives 9 Kcal.

Write a program that calculates and outputs how many calories all meals together give.

If the file calories.txt contains the following lines:

 40 53 14
 62 47 26
 49 43 20
 10 35 22

then the output of the program should be

 2094

Go to Moodle and upload your solution into Homework 1.

  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused