NodeJS Slip20b Solution

// Importing required modules
const http = require('http');

// Define the course structure for SYBBA (CA)
const sybbaCACourse = {
semester1: ['Financial Accounting', 'Business Economics', 'Business Mathematics', 'Computer Fundamentals', 'Communication Skills'],
semester2: ['Cost Accounting', 'Business Statistics', 'Business Environment', 'Programming in C', 'Principles of Management'],
semester3: ['Management Accounting', 'Income Tax', 'Auditing', 'Data Structures and Algorithms', 'Human Resource Management'],
semester4: ['Financial Management', 'Direct Tax', 'Indirect Tax', 'Database Management Systems', 'Marketing Management'],
semester5: ['Management Information Systems', 'Company Law', 'E-Commerce', 'Software Engineering', 'Entrepreneurship Development'],
semester6: ['Research Methodology', 'Financial Services', 'Management Accounting', 'International Business', 'Project Management']
};

// Create a HTTP server
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'}); // Set the response header
res.write('<h1>SYBBA (CA) Course Structure</h1>'); // Write the heading

// Loop through each semester and display the courses
for (let i = 1; i <= 6; i++) {
const semester = `semester${i}`;
res.write(`<h2>Semester ${i}:</h2><ul>`);
for (let j = 0; j < sybbaCACourse[semester].length; j++) {
res.write(`<li>${sybbaCACourse[semester][j]}</li>`);
}
res.write('</ul>');
}

res.end(); // End the response
});

// Start the server on port 3000
server.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
});

No comments:

Post a Comment