40 points
hey friends plz help me in all these questions
No spamming please...
Answers
Hi
To execute particular program you have to make separate file with basic html structure and then put code inside scrip tag.
Ques: 1;
var name = prompt('Enter your name:');
var address = prompt('Enter your address:');
var phone = prompt('Enter your telephone number:');
document.write(name + '<br>');
document.write(address + '<br>');
document.write(phone + '<br>');
Ques: 2;
var name = prompt('Enter your name:');
var age = prompt('Enter your age:');
document.write(name + ' is ' + age + ' years old.');
var age = prompt('Enter your age:');
var isIndian = prompt('Enter "indian " if you are indian:');
if (age >= 18 && isIndian == "indian") {
alert("Eligible for voting");
} else {
alert("You are not eligible for voting");
}
Ques: 3;
var number = parseInt(prompt("Enter number:"));
var counter = 1;
switch (counter) {
case 1:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 2:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 3:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 4:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 5:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 6:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 7:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 8:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 9:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
case 10:
document.write(number + " x " + counter + " = " + number * counter + "<br>");
counter++;
break;
}
Ques: 4;
var purchaseAmount = parseInt(prompt("Enter purchase amount:"));
var discountPercent = 0;
var discountMoney = 0;
var netAmount = 0;
if (purchaseAmount <= 5000) {
discount = 2;
discountMoney = (purchaseAmount / 100) * discount;
netAmount = purchaseAmount - discountMoney;
document.write("Net Amount: " + netAmount);
} else if (purchaseAmount > 5000 && purchaseAmount <= 10000) {
discount = 5;
discountMoney = (purchaseAmount / 100) * discount;
netAmount = purchaseAmount - discountMoney;
document.write("Net Amount: " + netAmount);
} else if (purchaseAmount > 10000) {
discount = 8;
discountMoney = (purchaseAmount / 100) * discount;
netAmount = purchaseAmount - discountMoney;
document.write("Net Amount: " + netAmount);
} else {
document.write("Error: Something went wrong!");
}
The following code is an example of the window.prompt method.
var customerName = prompt("Please enter your name", "");
if (customerName!= null) {
document.getElementById("welcome").innerHTML =
"Hello " + customerName + "! How are you today?";
computer common oriented machine particularly unioun
var customerName = prompt("Please enter your name", "");
if (customerName!= null) {
document.getElementById("welcome").innerHTML =
"Hello " + customerName + "! How are you today?";
}