В браузере консольный ввод организовать нереально.
В качестве среды исполнения использовал Node.js версии 12.18.3.
Иллюстрации кода, а также пример вывода добавлены во вложения.
=========================
Ваши оценки и отзывы лучше оценить качество ответа.
Если ответ удовлетворил, не забудь отметить его как "Лучший".
=========================
Код:
"use strict";
const readline = require('readline');
// IO realisation
(async function QNAThread(dialog) {
const qna = readline.createInterface({
input: process.stdin,
output: process.stdout
});
await dialog(function askMe(text) {
return new Promise((resolve, reject) => {
qna.question(text + " ", resolve);
});
});
qna.close();
})(mainDialog);
function firstTask() {
console.log("[Your name and lastname here]");
console.log("[Information about your group and university]");
}
function secondTask(a, b) {
return [(a+b)/2, Math.sqrt(a*b)];
}
function thirdTask(x) {
return Math.pow(Math.cos(Math.PI * x), 2) * Math.log(3*x);
}
function fifthTask(x) {
return (x*x*x - 5*x*x + 1) !== 10;
}
function sixth(x, b) {
return (x*x*x + 4*x > -1) && b;
}
// Here is the main script!
async function mainDialog(askMe) {
//Task #1
console.log("{First task}");
firstTask();
//Task #2
console.log("\n{Second task}");
console.log(`Answers for [A=4] and [B=7] are ${secondTask(4, 7)}\n`);
//Task #3
console.log("{Third task}");
let x = Number.parseFloat(await askMe("VVEDITE ZNACHENIE X:=\n"));
console.log(`PRI X=\t${x} znachenie Y=\t${thirdTask(x)}\n`);
//Task #4
console.log("{Fourth task}");
console.log(`1) При x=${x} значение функции y=\t${thirdTask(x)};`);
const inner = `2) При x=${x}`;
console.log(`${inner}\n${" ".repeat(inner.length)}\tзначение функции y=\t${thirdTask(x)};`);
console.log("*".repeat(40));
console.log(`3) При x=${x} \n\nзначение функции y=\t${thirdTask(x)};`);
console.log("*".repeat(40));
//Task #5
console.log("\n{Fifth task}");
x = Number.parseFloat(await askMe("Enter the X value:"));
console.log(`For x=${x} logical value of goal expression is \"${fifthTask(x)}\".`);
//Task #6
console.log("\n{Sixth task}");
x = 2;
const b = true;
console.log(`For [x=${x}] and [b=${b}] logical value of goal expression is ${sixth(x, b)}.`)
}
type Oras = (Chisinau, Orhei, Balti, Tigina, Tiraspol);
Zi = (L, Ma, Mi, J, V, S, D);
Consum = array [Oras, Zi] of real;
var C : Consum;
r : Oras;
z : Zi;
i,k : integer;
sum,min_r,max_r,min_z,max_z:real;
n_max_r,n_min_r,n_max_z,n_min_z:integer;
begin
r:=Chisinau;
randomize;
for i:=1 to 5 do
begin
z:=L;
for k:=1 to 7 do
begin
c[r,z]:=random*100;
z:=succ(z);
end;
r:=succ(r);
end;
r:=Chisinau;
for i:=1 to 5 do
begin
z:=L;
case ord(r) of
0:writeln('Chisinau');
1:writeln('Orhei');
2:writeln('Balti');
3:writeln('Tigina');
4:writeln('Tiraspol');
end;
for k:=1 to 7 do
begin
write(c[r,z]:6:2);
z:=succ(z);
end;
r:=succ(r);
writeln;
end;
writeln('Vsego za nedelu');
r:=Chisinau;
min_r:=99999;
max_r:=0;
n_min_r:=-1;
n_max_r:=-1;
for i:=1 to 5 do
begin
z:=L;
case ord(r) of
0:write('Chisinau sum=');
1:write('Orhei sum=');
2:write('Balti sum=');
3:write('Tigina sum=');
4:write('Tiraspol sum=');
end;
sum:=0;
for k:=1 to 7 do
begin
sum:=sum+c[r,z];
z:=succ(z);
end;
if sum>max_r then
begin
max_r:=sum;
n_max_r:=ord(r);
end;
if sum<min_r then
begin
min_r:=sum;
n_min_r:=ord(r);
end;
r:=succ(r);
writeln(sum:8:2);
end;
writeln('Po dnyam nedeli');
z:=L;
min_z:=99999;
max_z:=0;
n_min_z:=-1;
n_max_z:=-1;
for k:=1 to 7 do
begin
r:=Chisinau;
case ord(z) of
0:write('L sum=');
1:write('Ma sum=');
2:write('Mi sum=');
3:write('J sum=');
4:write('V sum=');
5:write('S sum=');
6:write('D sum=');
end;
sum:=0;
for i:=1 to 5 do
begin
sum:=sum+c[r,z];
r:=succ(r);
end;
if sum>max_z then
begin
max_z:=sum;
n_max_z:=ord(z);
end;
if sum<min_z then
begin
min_z:=sum;
n_min_z:=ord(z);
end;
z:=succ(z);
writeln(sum:8:2);
end;
writeln('Gorod c maximalnim potrebleniem');
r:=Chisinau;
for i:=1 to 5 do
begin
if ord(r)=n_max_r then
case ord(r) of
0:writeln('Chisinau');
1:writeln('Orhei');
2:writeln('Balti');
3:writeln('Tigina');
4:writeln('Tiraspol');
end;
r:=succ(r);
end;
writeln('Gorod c minimalnim potrebleniem');
r:=Chisinau;
for i:=1 to 5 do
begin
if ord(r)=n_min_r then
case ord(r) of
0:writeln('Chisinau');
1:writeln('Orhei');
2:writeln('Balti');
3:writeln('Tigina');
4:writeln('Tiraspol');
end;
r:=succ(r);
end;
writeln('Den c maximalnim potrebleniem');
z:=L;
for k:=1 to 7 do
begin
if ord(z)=n_max_z then
case ord(z) of
0:writeln('L');
1:writeln('Ma');
2:writeln('Mi');
3:writeln('J');
4:writeln('V');
5:writeln('S');
6:writeln('D');
end;
z:=succ(z);
end;
writeln('Den c minimalnim potrebleniem');
z:=L;
for k:=1 to 7 do
begin
if ord(z)=n_min_z then
case ord(z) of
0:writeln('L');
1:writeln('Ma');
2:writeln('Mi');
3:writeln('J');
4:writeln('V');
5:writeln('S');
6:writeln('D');
end;
z:=succ(z);
end;
readln;
end.