├── index.html
└── script.js
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Math Expression 2
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/script.js:
--------------------------------------------------------------------------------
1 | // Q1 : Write a program to take a number in a variable do the require arithematic to display result
2 |
3 | let a = 10;
4 | document.write(`The value of a is: ${a}
`);
5 | document.write(`The value of ++a is: ${++a}
`);
6 | document.write(`Now the value of a is: ${a}
`);
7 | document.write(`The value of a++ is: ${a++}
`);
8 | document.write(`Now the value of a is: ${a}
`);
9 | document.write(`The value of --a is: ${--a}
`);
10 | document.write(`Now the value of a is: ${a}
`);
11 | document.write(`The value of a-- is: ${a--}
`);
12 | document.write(`Now the value of a is: ${a}
`);
13 |
14 | // Q2 : What Will Be The Output Of Variables a,b & result after execution of the following script
15 | // let a = 2 ; let b = 1; let res = --a - --b + ++b + b--;
16 |
17 | let x = 2;
18 | let y = 1;
19 | let results = --x - --y + ++y + y--;
20 | document.write(`The Value of x At Last is ${x}
`);
21 | document.write(`The Value of y At Last is ${y}
`);
22 | document.write(`The Final Result Of The Calculation is ${results}
`);
23 |
24 | // Q3: Write The Program That Takes The Input a name From User And Greet That Person:
25 |
26 | let userInput = prompt("Enter Your Name");
27 | alert(`Welcome ${userInput} To My Web Page`);
28 |
29 | // Q4: Write a program to take input a number from user &
30 | // display it’s multiplication table on your browser. If user
31 | // does not enter a new number, multiplication table of 5
32 | // should be displayed by default.
33 |
34 | let tableNumber = +prompt("Enter a Number Of Table You Want To Print", 5);
35 | for (let i = 1; i <= 10; i++) {
36 | document.write(`${tableNumber} X ${i} = ${tableNumber * i}
`);
37 | }
38 |
39 | // Q5:
40 | // a) Take three subjects name from user and store them in 3 different variables
41 | // b) Total marks for each subject is 100, store it in another variable
42 | // c) Take obtained marks for first subject from user and stored it in different variable
43 | // d) Take obtained marks for remaining 2 subjects from user and store them in variables
44 | // e) Now calculate total marks and percentage and show the result in browser like this.
45 | // (Hint: user table)
46 |
47 | const subject1 = prompt("Enter the name of the first subject:");
48 | const subject2 = prompt("Enter the name of the second subject:");
49 | const subject3 = prompt("Enter the name of the third subject:");
50 | const totalMarks = 100;
51 | const obtainedMarks1 = parseFloat(prompt(`Enter the obtained marks in ${subject1}:`));
52 | const obtainedMarks2 = parseFloat(prompt(`Enter the obtained marks in ${subject2}:`));
53 | const obtainedMarks3 = parseFloat(prompt(`Enter the obtained marks in ${subject3}:`));
54 | const totalObtainedMarks = obtainedMarks1 + obtainedMarks2 + obtainedMarks3;
55 | const percentage = (totalObtainedMarks / (totalMarks * 3)) * 100;
56 | const result = `
57 |
58 |
59 | Subject |
60 | Total Marks |
61 | Obtained Marks |
62 |
63 |
64 | ${subject1} |
65 | ${totalMarks} |
66 | ${obtainedMarks1} |
67 |
68 |
69 | ${subject2} |
70 | ${totalMarks} |
71 | ${obtainedMarks2} |
72 |
73 |
74 | ${subject3} |
75 | ${totalMarks} |
76 | ${obtainedMarks3} |
77 |
78 |
79 | Total |
80 | ${totalObtainedMarks} |
81 |
82 |
83 | Percentage |
84 | ${percentage.toFixed(2)}% |
85 |
86 |
87 | `;
88 | document.write(`
${result}`);
--------------------------------------------------------------------------------