Volddemar4ik il y a 2 ans
Parent
commit
52a6119b8b
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      js/01/HW1.js

+ 4 - 4
js/01/HW1.js

@@ -6,18 +6,18 @@ const lightNightRate = +prompt('Введите стоимость кВт/час
 
 
 const daysInMonth = +prompt('Кол-во дней в месяце:', 'дней')
 const daysInMonth = +prompt('Кол-во дней в месяце:', 'дней')
 
 
-const priceDay = lightDayUse * lightDayRate
+const priceDay = +((lightDayUse * lightDayRate).toFixed(2))
 const priceDayAlert = 'Стоимость потребленной электроэнергии в дневное время: ' + priceDay + ' грн.'
 const priceDayAlert = 'Стоимость потребленной электроэнергии в дневное время: ' + priceDay + ' грн.'
 alert(priceDayAlert);
 alert(priceDayAlert);
 
 
-const priceNight = lightNightUse * lightNightRate
+const priceNight = +((lightNightUse * lightNightRate).toFixed(2))
 const priceNightAlert = 'Стоимость потребленной электроэнергии в ночное время: ' + priceNight + ' грн.'
 const priceNightAlert = 'Стоимость потребленной электроэнергии в ночное время: ' + priceNight + ' грн.'
 alert(priceNightAlert);
 alert(priceNightAlert);
 
 
-priceMonth = priceDay + priceNight
+priceMonth = (priceDay + priceNight).toFixed(2)
 const priceMonthAlert = 'Стоимость потребленной электроэнергии в месяц: ' + priceMonth + ' грн.'
 const priceMonthAlert = 'Стоимость потребленной электроэнергии в месяц: ' + priceMonth + ' грн.'
 alert(priceMonthAlert);
 alert(priceMonthAlert);
 
 
-const usePerDay = (lightDayUse + lightNightUse) / daysInMonth
+const usePerDay = ((lightDayUse + lightNightUse) / daysInMonth).toFixed(2)
 const usePerDayAlert = 'Среднее потребление в день: ' + usePerDay + '  кВт/ч.'
 const usePerDayAlert = 'Среднее потребление в день: ' + usePerDay + '  кВт/ч.'
 alert(usePerDayAlert);
 alert(usePerDayAlert);