0% found this document useful (0 votes)
30 views6 pages

Sir Zafer Bhutto Codding

The document contains JavaScript code examples demonstrating various programming concepts such as data types, operators, conditional statements, and user input handling. It includes operations like addition, multiplication, and the calculation of a student's marks and grades. Additionally, it showcases how to dynamically generate HTML content using JavaScript to display results.

Uploaded by

Imtiaz Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views6 pages

Sir Zafer Bhutto Codding

The document contains JavaScript code examples demonstrating various programming concepts such as data types, operators, conditional statements, and user input handling. It includes operations like addition, multiplication, and the calculation of a student's marks and grades. Additionally, it showcases how to dynamically generate HTML content using JavaScript to display results.

Uploaded by

Imtiaz Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

CLASS CODING ITC-509 (WEB SYSTEM &TECHNOLOGY)

var a=10;
var b=10;
var add = a+b;
document.write(add);
console.log(add);

/// permites data type


/// non permites data type

let a = 50;
let b= 20;
let c= 5.5;
let d= 5.5;
let var_int = a+b;
let var_float = c+d;

document.write(" int value:- "+ var_int," float_vlaue"+var_float);


document.write("\n");
document.write("i would not buy the some apple in "+var_int)

/// String
let s = "Sau.Tandojaam";
document.write(" The univerity name is "+s);
/// boolein
let bol = true;

/// undefined
let f;

/// null
let emp = null;

/// symbol

let sym = Symbol("this is the ojbec to call the key"),

/// bigint

bigint = 123445667;

let my_fav_fruit= "Apple";


let is_fav=false;

if(my_fav_fruit = is_fav ){
document.write('your favoirte fruit is apple is Apple');

}else{
document.write("your favoirte fruit is not APPLE");
}

/// operators
/// 20/2/2025

var a = 10;
var b = 25;
var additon = a + b;
document.write("\nadditon = " + additon);

var multiplication = a * b
document.write("\nmultiplication = " + multiplication);

var division = a / b
document.write("\ndivision = " + division);
var substraction = a - b
document.write("\nsubstraction = " + substraction);
var modulo = a % b
document.write("\nmodulo = " + modulo);

var a = 10;

a += 10;
document.write("a += 10 → " + a + "<br><br>");

a -= 10;
document.write("a -= 5 → " + a + "<br><br>");

a /= 10;
document.write("a /= 4 → " + a + "<br><br>");

a %= 1;
document.write("a %= 1 → " + a + "<br><br>");

a += 2;
document.write("a += 2 → " + a + "<br><br>");
a **= 10;
document.write("a **= 2 → " + a + "<br><br>");

const num = prompt("Enter any number");


const squire = num*num;
document.write("squire of num: "+ squire);

let a= Number(prompt("Ente any number"));


let b= Number(prompt("Enter Second value"));
let additon =a+b;
let sub =a-b;
let mul =a*b;
let div =a/b;
document.write("additon "+additon +"<br>");
document.write("sub "+sub+"<br>");
document.write("mul "+mul+"<br>");
document.write("div "+div+"<br>");

let a = Number(prompt("Enter any a: "));


let b = Number(prompt("Enter second b: "));

let temp = a;
a = b;
b = temp;

document.write("After swapping: a =", a, ", b =", b);

/// conditionla statement

a =10;
b=20;
if(a<b){
document.write("true");
}

let a = prompt("Enter First Value");


let b = prompt("Enter Second Value");
if(a<b){
document.write("true");
}else{
document.write("false");

let num = prompt("Enter First Value");


// let b = prompt("Enter Second Value");
if (num => 50) {
document.write("alllowed");
} else {
document.write("not alllowed");

let num = prompt("Enter Number");


if (num >= 1 && num<=50) {
document.write("Alllowed");
} else if (num >= 51 && num<=100) {
document.write("Allowed");

} else {
document.write("Not Allowed");

// JavaScript Marksheet using document.write()

// Getting subject marks from user


var subjects = ['Math', 'Science', 'English', 'Computer', 'Physics'];
var totalMarks = 500;
var obtainedMarks = 0;
var marks = {};
let user_name;
user_name = prompt("Enter Your Name");

for (var i = 0; i < subjects.length; i++) {


var mark = parseInt(prompt("Enter marks for " + subjects[i] + " (out
of 100):"));
if (isNaN(mark) || mark < 0 || mark > 100) {
alert("Please enter a valid number between 0 and 100");
i--; // Repeat the same subject input if invalid
} else {
marks[subjects[i]] = mark;
obtainedMarks += mark;
}
}

// Calculate percentage and grade


var percentage = (obtainedMarks / totalMarks) * 100;
var grade = "";

if (percentage >= 90) {


grade = "A+";
} else if (percentage >= 80) {
grade = "A";
} else if (percentage >= 70) {
grade = "B";
} else if (percentage >= 60) {
grade = "C";
} else if (percentage >= 50) {
grade = "D";
} else {
grade = "Fail";
}

// Display result using document.write()


document.write("<style>");
document.write("body { font-family: Arial, sans-serif; background-color:
#f4f4f4; text-align: center; }");
document.write("h2 { color: #333; }");
document.write("table { width: 50%; margin: auto; border-collapse:
collapse; background: #fff; box-shadow: 0px 0px 10px
rgba(0,0,0,0.1); }");
document.write("th, td { padding: 10px; border: 1px solid #ddd; text-
align: center; }");
document.write("th { background: #500e2f; color: #fff; }");
document.write("td { font-weight: bold; }");
document.write("</style>");

document.write("<h2>Student Marksheet</h2>");
document.write("Your Name is "+user_name);
document.write("<table>");
document.write("<tr><th>Subject</th><th>Marks</th></tr>");
for (var subject in marks) {
document.write("<tr><td>" + subject + "</td><td>" + marks[subject] +
"</td></tr>");
}
document.write("<tr><td><strong>Total Marks</strong></td><td>" +
obtainedMarks + "/500</td></tr>");
document.write("<tr><td><strong>Percentage</strong></td><td>" +
percentage.toFixed(2) + "%</td></tr>");
document.write("<tr><td><strong>Grade</strong></td><td style='color: " +
(grade === 'Fail' ? "red" : "green") + ";'>" + grade + "</td></tr>");
document.write("</table>");

You might also like