Практикум по программированию. Основы. Ввод и вывод. Выполнение плана
From AsIsWiki
(Difference between revisions)
Line 95: | Line 95: | ||
readln; | readln; | ||
end. | end. | ||
+ | </source> | ||
+ | |||
+ | |||
+ | ==JavaScript== | ||
+ | |||
+ | <source lang="js"> | ||
+ | <html lang="ru"> | ||
+ | <head> | ||
+ | <meta charset="UTF-8"> | ||
+ | <script> | ||
+ | function calc() { | ||
+ | var p = document.getElementById("pId").value; | ||
+ | var f = document.getElementById("fId").value; | ||
+ | |||
+ | var pr = f / p * 100; | ||
+ | |||
+ | document.getElementById("resultId").innerHTML = | ||
+ | "Процент выполнения плана: " + pr.toFixed(2) + "%"; | ||
+ | } | ||
+ | </script> | ||
+ | </head> | ||
+ | <body> | ||
+ | |||
+ | <p>Расчет процента выполнения плана</p> | ||
+ | <hr> | ||
+ | <p>Введите плановый показатель: <input id="pId" size="5"></p> | ||
+ | <p>Введите фактический показатель: <input id="fId" size="5"></p> | ||
+ | <hr> | ||
+ | <p id="resultId"></p> | ||
+ | |||
+ | <button onclick="calc()">Рассчитать</button> | ||
+ | |||
+ | </body> | ||
+ | </html> | ||
</source> | </source> | ||
Revision as of 09:25, 13 March 2016
Contents |
Java
import java.util.Scanner; public class Task04 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println(); System.out.println(" Расчет процента выполнения плана"); System.out.println("----------------------------------"); System.out.print(" Введите плановый показатель: "); double p = in.nextDouble(); System.out.print(" Введите фактический показатель: "); double f = in.nextDouble(); System.out.println("----------------------------------"); double pr = f / p * 100; System.out.printf(" Процент выполнения плана: %.2f%%\n", pr); } }
C++
// g++ 4.2 #include <iostream> using namespace std; int main() { double p, f; cout << "\n Расчет процента выполнения плана\n"; cout << "----------------------------------\n"; cout << " Введите плановый показатель: "; cin >> p; cout << " Введите фактический показатель: "; cin >> f; cout << "----------------------------------\n"; double pr = f / p * 100; printf(" Процент выполнения плана: %.2f%%\n\n", pr); return 0; }
Pascal
program Task04; var p, f, pr: real; begin writeln; writeln(' Расчет процента выполнения плана'); writeln('----------------------------------'); write(' Введите плановый показатель: '); readln(p); write(' Введите фактический показатель: '); readln(f); writeln('----------------------------------'); pr := f / p * 100; writeln(' Процент выполнения плана: ', pr:0:2, '%'); readln; end.
JavaScript
<html lang="ru"> <head> <meta charset="UTF-8"> <script> function calc() { var p = document.getElementById("pId").value; var f = document.getElementById("fId").value; var pr = f / p * 100; document.getElementById("resultId").innerHTML = "Процент выполнения плана: " + pr.toFixed(2) + "%"; } </script> </head> <body> <p>Расчет процента выполнения плана</p> <hr> <p>Введите плановый показатель: <input id="pId" size="5"></p> <p>Введите фактический показатель: <input id="fId" size="5"></p> <hr> <p id="resultId"></p> <button onclick="calc()">Рассчитать</button> </body> </html>