Практикум по программированию. Основы. Ввод и вывод. Выполнение плана

From AsIsWiki
Jump to: navigation, search

Назад · Задачи · Дальше


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;
}


Python

# Python 3

print('\n Расчет процента выполнения плана')
print('----------------------------------')

p = float(input(' Введите плановый показатель: '))
f = float(input(' Введите фактический показатель: '))

print('----------------------------------')

pr = f / p * 100

print(' Процент выполнения плана: %.2f%%' % pr)


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>



Назад · Задачи · Дальше

Personal tools
Namespaces

Variants
Actions
Navigation
Tools