From ea3cdfbf03eba83ec59de419ce2c5738d0910521 Mon Sep 17 00:00:00 2001 From: nadya12082012 <96071893+nadya12082012@users.noreply.github.com> Date: Thu, 3 Nov 2022 17:56:26 +0300 Subject: [PATCH] Add files via upload done zadanie_4 --- index.html | 13 +++++++++++++ zadanie_4.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 index.html create mode 100644 zadanie_4.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..c66dd77 --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + Document + + + + + + \ No newline at end of file diff --git a/zadanie_4.js b/zadanie_4.js new file mode 100644 index 0000000..04ee926 --- /dev/null +++ b/zadanie_4.js @@ -0,0 +1,44 @@ +"use strict" +let balans = Number (prompt( 'Введите сумму, которой располагаете')); +const pricePhon = 15; //стоимость телефона +const acsessoriesP = 5; // стоимость аксессуаров +const nalog = pricePhon*20/100; // налог +let sum = pricePhon + acsessoriesP + nalog; // стоимость комплекта телефон+аксессуар +let sumPhNal = pricePhon + nalog; // цена телефона с налогом +let acsnal = acsessoriesP + (acsessoriesP*20/100); // аксессуары с налогом +let phoneP = 0; +let accesoriesPr = 0; +let phoneN = 0; +let accesoriesN = 0; + +while (balans > sum ){ +if (balans >=sum ) { + balans = balans - sum; + phoneN += sumPhNal; + accesoriesN += acsnal; + phoneP++; + accesoriesPr++; + +} +else{ + if(balans >= acsnal && balans <= sumPhNal) { + balans -= acsnal; + accesoriesN +=acsnal; + accesoriesN++ + } + else{ + break; + } + } + + } + + alert("Вы можете купить телефонов:" + phoneP); + alert("Вы можете купить аксессуаров:" + accesoriesPr); + + if (balans