Menu

NPTEL SOLUTIONS

Human Computer Interaction (In English) 12 Weeks Course

Week 3 : Assignment 3


Week 4 : Assignment 4



Blockchain and its Applications

Week 3 : Assignment 3


Week 4 : Assignment 4

Express js, React js and Mongo DB

Syllabus

Exercise - 1: Express JS – Routing, HTTP Methods
1a. Write a program to define a route, Handling Routes, Route Parameters, Query Parameters and URL building.
const express = require('express');
const app = express();

// Middleware to parse JSON request bodies
app.use(express.json());

//  user data stored in memory
const users = {
  1: { id: 1201, name: 'DIET', email: '1201@diet.ac.in' },
  2: { id: 1202, name: 'IT DEPT', email: '1202@diet.ac.in' }
};

// Home route
app.get('/', (req, res) => {
  res.send('Welcome to the User API!');
});

// Get all users or filter by name using query parameter
app.get('/users', (req, res) => {
  const name = req.query.name;
  let result = Object.values(users);  //to convert the object to an array
  if (name) {
    result = result.filter(user => user.name.toLowerCase() === name.toLowerCase());
  }
  res.json(result);
});

// Get a specific user by route parameter (user ID)
app.get('/users/:id', (req, res) => {
  const user = users[req.params.id];
  if (user) {
    res.json(user);
  } else {
    res.status(404).send('User not found');
  }
});

// Build a sample URL for a user
app.get('/build-url/:id', (req, res) => {
  const id = req.params.id;
  const fullUrl = `${req.protocol}://${req.get('host')}/users/${id}`;
  res.send(`User URL: ${fullUrl}`);
});

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

1b. Write a program to accept data, retrieve data and delete a specified resource using http methods.
 // app.js
const express = require('express');
const app = express();
const port = 3000;

// Middleware to parse JSON from request bodies
app.use(express.json());

// database to store users
let users = {
  1: { id: 1201, name: 'DIET', email: '1201@diet.ac.in' },
  2: { id: 1202, name: 'IT DEPT', email: '1202@diet.ac.in' }
};

//  Add a new user
app.post('/users', (req, res) => {
  const { id, name, email } = req.body;
  if (!id || !name || !email) {
    return res.status(400).send('Please provide id, name, and email');
  }
  if (users[id]) {
    return res.status(409).send('User already exists');
  }
  users[id] = { id, name, email };
  res.status(201).json(users[id]);
});

//  Get all users
app.get('/users', (req, res) => {
  res.json(Object.values(users));
});

//  Get user by ID
app.get('/users/:id', (req, res) => {
  const id = req.params.id;
  const user = users[id];
  if (!user) {
    return res.status(404).send('User not found');
  }
  res.json(user);
});

//  Delete user by ID
app.delete('/users/:id', (req, res) => {
  const id = req.params.id;
  if (!users[id]) {
    return res.status(404).send('User not found');
  }
  delete users[id];
  res.send(`User with ID ${id} deleted`);
});

//  Update Resource - update user by ID
app.put('/users/:id', (req, res) => {
  const id = req.params.id;
  const { name, email } = req.body;

  // Check if user exists
  if (!users[id]) {
    return res.status(404).send('User not found');
  }

  // Validate input
  if (!name || !email) {
    return res.status(400).send('Please provide both name and email');
  }

  // Update user details
  users[id].name = name;
  users[id].email = email;

  res.send(` User with ID ${id} updated successfully`);
});
  
// Start the server
app.listen(port, () => {
  console.log(`Server running at http://localhost:${port}`);
});



Exercise - 2: Express JS – Templating, Form Data
2a.Write a program using templating engine.
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');

const app = express();

// Set up EJS as the templating engine
app.set('view engine', 'ejs');

// Use body-parser to parse incoming form data
app.use(bodyParser.urlencoded({ extended: true }));

// Serve static files (like CSS) from the "public" directory
app.use(express.static(path.join(__dirname, 'views')));

// Route to display the form
app.get('/', (req, res) => {
  res.render('index');  // Render the "index.ejs" template
});

// Route to handle form submission
app.post('/submit', (req, res) => {
  const { name, email } = req.body;
  // Render the result page and pass the submitted data
  res.render('result', { name, email });
});

// Start the server
app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});
2b.Write a program to work with form data.


Exercise - 3: Express JS – Cookies, Sessions, Authentication
  • 3a. Write a program for session management using cookies and sessions
  • 3b. Write a program for user authentication.


Exercise-4: Express JS – Database, RESTful APIs
  • 4a. Write a program to connect MongoDB database using Mangoose and perform CRUD operations.
  • 4b.Write a program to develop a single page application using RESTful APIs.


Exercise-5: React JS – Render HTML, JSX, Components – function and Class
  • 5a.Write a program to render HTML to a web page
  • 5 b.Write a program for writing markup with JSX.
  • 5 c.Write a program for creating and nesting components (function and class).


Exercise-6: React JS – Props and States, Styles, Respond to Events
  • 6a.Write a program to work with props and states.
  • 6b.Write a program to add styles (CSS & Sass Styling) and display data.
  • 6c.Write a program for responding to events.


Exercise-7: React JS – Conditional Rendering, Rendering Lists, React Forms
  • 7a.Write a program for conditional rendering.
  • 7b.Write a program for rendering lists.
  • 7c.Write a program for working with different form fields using react forms.


Exercise-8: React JS – React Router, Updating the Screen
  • 8a.Write a program for routing to different pages using react router.
  • 8a.Write a program for routing to different pages using react router.


  • Exercise-9: React JS – Hooks, Sharing data between Components
    • 9a.Write a program to understand the importance of using hooks.
    • 9b.Write a program for sharing data between components.

User Interface Design using Flutter

Exercise - 1: Flutter and Dart SDK
1b. Write a simple Dart program to understand the basic language.
// Source: kottesandeep.blogspot.com
// hello.dart
void main() {
  print('Hello, Dart!');

  // Variables
  String name = 'Alice';
  int age = 25;
  double height = 5.6;
  bool isStudent = true;

  // Lists
  List hobbies = ['reading', 'coding', 'hiking'];

   // Function call
  greetUser(name);

  // Control flow
  if (age >= 18) {
    print('$name is an adult.');
  } else {
    print('$name is a minor.');
  }

  // Loop
  print('Hobbies:');
  for (var hobby in hobbies) {
    print('- $hobby');
  }
}

// Function definition
void greetUser(String username) {
  print('Welcome, $username!');
}



Exercise - 2:
2. a) Explore various Flutter widgets (Text, Image, Container, etc.).
Text('Hello, World!',style: TextStyle(fontSize: 24, color: Colors.red),),
            
Image.file(File('asset/images/Screenshot.png'), width: 200, height: 200,),
Container(
   padding: EdgeInsets.all(16),
   color: Colors.green,
   child: Text('Inside a container'),
 )

2. b) Implement different layout structures using Row, Column, and Stack Widget.
mainAxisAlignment: MainAxisAlignment.center,
          children: < Widget >[
            Text('Username'),
            SizedBox(height: 20),
            Text('Password'),
            SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {},
              child: Text('Click Me'),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                Icon(Icons.home, size: 40),
                Icon(Icons.search, size: 40),
                Icon(Icons.settings, size: 40),
              ],
            ),

            Stack(
              alignment: Alignment.center,
              children: [
                Container(
                  width: 200,
                  height: 200,
                  color: Colors.blue,
                ),
                Container(
                  width: 100,
                  height: 100,
                  color: Colors.red,
                ),
                Text(
                  'Center',
                  style: TextStyle(color: Colors.white, fontSize: 20),
                ),
              ],
            )


Exercise - 3:
3 a) Design a responsive UI that adapts to different screen sizes.
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Responsive UI Demo',
      home: ResponsiveUI(),  // <- This is your Scaffold-based widget
    );
  }
}

class ResponsiveUI extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;

    return Scaffold(
      appBar: AppBar(title: Text("Responsive UI")),
      body: LayoutBuilder(
        builder: (context, constraints) {
          if (constraints.maxWidth > 600) {
            // Tablet/Desktop Layout
            return Row(
              children: [
                Expanded(child: Container(color: Colors.blue, child: Center(child: Text("Sidebar")))),
                Expanded(flex: 2, child: Container(color: Colors.white, child: Center(child: Text("Main Content")))),
              ],
            );
          } else {
            // Mobile Layout
            return Column(
              children: [
                Container(height: 100, color: Colors.blue, child: Center(child: Text("Top Bar"))),
                Expanded(child: Container(color: Colors.white, child: Center(child: Text("Main Content")))),
              ],
            );
          }
        },
      ),
    );
  }
}


3 b) Implement media queries and breakpoints for responsiveness.
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

// Root widget
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Media Query Breakpoints Demo',
      home: ResponsiveLayout(),
    );
  }
}

// Main responsive widget using breakpoints
class ResponsiveLayout extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    double screenWidth = MediaQuery.of(context).size.width;

    if (screenWidth < 600) {
      // Small screen: Mobile
      return Scaffold(
        appBar: AppBar(title: Text("Mobile Layout")),
        body: Center(child: Text("This is a Mobile Layout", style: TextStyle(fontSize: 16))),
      );
    } else if (screenWidth >= 600 && screenWidth < 1200) {
      // Medium screen: Tablet
      return Scaffold(
        appBar: AppBar(title: Text("Tablet Layout")),
        body: Center(child: Text("This is a Tablet Layout", style: TextStyle(fontSize: 20))),
      );
    } else {
      // Large screen: Desktop
      return Scaffold(
        appBar: AppBar(title: Text("Desktop Layout")),
        body: Center(child: Text("This is a Desktop Layout", style: TextStyle(fontSize: 24))),
      );
    }
  }
}



Exercise - 4:
4 a) Set up navigation between different screens using Navigator.
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

// Root widget
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Navigator Demo',
      home: FirstScreen(),
    );
  }
}

// First Screen
class FirstScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("First Screen")),
      body: Center(
        child: ElevatedButton(
          child: Text("Go to Second Screen"),
          onPressed: () {
            // Navigation using direct push
            Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => SecondScreen()),
            );
          },
        ),
      ),
    );
  }
}

// Second Screen
class SecondScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Second Screen")),
      body: Center(
        child: ElevatedButton(
          child: Text("Back to First Screen"),
          onPressed: () {
            Navigator.pop(context); // Go back
          },
        ),
      ),
    );
  }
}

4 b) Implement navigation with named routes.
 import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Named Routes Demo',
      initialRoute: '/',
      routes: {
        '/': (context) => HomeScreen(),
        '/second': (context) => SecondScreen(),
      },
    );
  }
}

// Home Screen
class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Home Screen")),
      body: Center(
        child: ElevatedButton(
          child: Text("Go to Second Screen"),
          onPressed: () {
            Navigator.pushNamed(context, '/second'); // Using named route
          },
        ),
      ),
    );
  }
}

// Second Screen
class SecondScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Second Screen")),
      body: Center(
        child: ElevatedButton(
          child: Text("Back to Home"),
          onPressed: () {
            Navigator.pop(context); // Go back
          },
        ),
      ),
    );
  }
}
 


Exercise - 5:
5 a) Learn about stateful and stateless widgets.
 1. Stateless Widget
	A StatelessWidget is immutable: once it is built, it cannot change its state during runtime.
	Used when the UI does not depend on dynamic data (e.g., labels, static layouts). 
 2. Stateful Widget
	A StatefulWidget can change during runtime using setState(). 

StatelessWidget → UI never changes.

StatefulWidget → UI can change with setState().

5 b) Implement state management using set State and Provider.
//Add provider to pubspec.yaml:
//dependencies:
//  flutter:
//    sdk: flutter
//  provider: ^6.0.5


import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

// State Class
class CounterModel with ChangeNotifier {
  int _count = 0;

  int get count => _count;

  void increment() {
    _count++;
    notifyListeners(); // notifies all listening widgets
  }
}

void main() {
  runApp(
    ChangeNotifierProvider(
      create: (_) => CounterModel(),
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: CounterScreen());
  }
}

class CounterScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var counter = Provider.of<CounterModel>(context);

    return Scaffold(
      appBar: AppBar(title: Text("Provider Example")),
      body: Center(
        child: Text("Count: ${counter.count}", style: TextStyle(fontSize: 24)),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => counter.increment(),
        child: Icon(Icons.add),
      ),
    );
  }
}


Exercise - 6:
6 a) Create custom widgets for specific UI elements.
 
  import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("Simple Avatar UI")),
        body: Center(
          child: CustomAvatar(
            imageUrl: "imageUrl",
            name: "Sandeep",
          ),
        ),
      ),
    );
  }
}

//  Custom Widget (Avatar)
class CustomAvatar extends StatelessWidget {
  final String imageUrl;
  final String name;

  CustomAvatar({required this.imageUrl, required this.name});

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        CircleAvatar(
          radius: 50,
          backgroundImage: NetworkImage(imageUrl),
        ),
        SizedBox(height: 10),
        Text(
          name,
          style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
        ),
      ],
    );
  }
}
   

6 b) Apply styling using themes and custom styles.
 
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Theming Example",

      // Global Theme
      theme: ThemeData(
        primarySwatch: Colors.teal,
        textTheme: TextTheme(
          bodyMedium: TextStyle(fontSize: 16, color: Colors.black87),
          titleLarge: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
        ),
      ),

      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Themes & Styles"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // Uses global theme (titleLarge)
            Text(
              "Welcome to Flutter!",
              style: Theme.of(context).textTheme.titleLarge,
            ),
            SizedBox(height: 20),

            // Custom Style applied locally
            Text(
              "This text has custom style",
              style: TextStyle(
                fontSize: 18,
                color: Colors.purple,
                fontWeight: FontWeight.w600,
                letterSpacing: 1.2,
              ),
            ),
            SizedBox(height: 20),

            // Widget with custom background styling
            Container(
              padding: EdgeInsets.all(12),
              decoration: BoxDecoration(
                color: Colors.teal.shade100,
                borderRadius: BorderRadius.circular(12),
              ),
              child: Text(
                "Styled Container",
                style: TextStyle(fontSize: 16, color: Colors.teal.shade900),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
     


Exercise - 7:
7 a) and b) Design a form with various input fields. Implement form validation and error handling
 
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Form Validation Example",
      home: FormScreen(),
    );
  }
}

class FormScreen extends StatelessWidget {
  final _formKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Form with Validation")),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Form(
          key: _formKey,
          child: Column(
            children: [
              // Name Field
              TextFormField(
                decoration: InputDecoration(labelText: "Name"),
                validator: (value) {
                  if (value == null || value.isEmpty) {
                    return "Name is required";
                  }
                  return null;
                },
              ),

              // Email Field
              TextFormField(
                decoration: InputDecoration(labelText: "Email"),
                keyboardType: TextInputType.emailAddress,
                validator: (value) {
                  if (value == null || value.isEmpty) {
                    return "Email is required";
                  }
                  if (!value.contains("@")) {
                    return "Enter a valid email";
                  }
                  return null;
                },
              ),

              // Password Field
              TextFormField(
                decoration: InputDecoration(labelText: "Password"),
                obscureText: true,
                validator: (value) {
                  if (value == null || value.length < 6) {
                    return "Password must be at least 6 characters";
                  }
                  return null;
                },
              ),

              // Age Field
              TextFormField(
                decoration: InputDecoration(labelText: "Age"),
                keyboardType: TextInputType.number,
                validator: (value) {
                  if (value == null || value.isEmpty) {
                    return "Age is required";
                  }
                  if (int.tryParse(value) == null) {
                    return "Enter a valid number";
                  }
                  return null;
                },
              ),

              SizedBox(height: 20),

              ElevatedButton(
                onPressed: () {
                  if (_formKey.currentState!.validate()) {
                    ScaffoldMessenger.of(context).showSnackBar(
                      SnackBar(content: Text("Form Submitted Successfully!")),
                    );
                  }
                },
                child: Text("Submit"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}



Exercise - 8:
a) Add animations to UI elements using Flutter's animation framework.
       
     import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: AnimationExample(),
    );
  }
}

class AnimationExample extends StatefulWidget {
  @override
  _AnimationExampleState createState() => _AnimationExampleState();
}

class _AnimationExampleState extends State
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  late Animation _animation;

  @override
  void initState() {
    super.initState();

    _controller = AnimationController(
      duration: Duration(seconds: 2),
      vsync: this,
    )..repeat(reverse: true); // Repeat animation back and forth

    _animation = Tween(begin: 100, end: 200).animate(_controller);
  }

  @override
  void dispose() {
    _controller.dispose(); // free memory
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Basic Animation Example")),
      body: Center(
        child: AnimatedBuilder(
          animation: _animation,
          builder: (context, child) {
            return Container(
              width: _animation.value,
              height: _animation.value,
              color: Colors.blue,
            );
          },
        ),
      ),
    );
  }
}

  • b) Experiment with different types of animations (fade, slide, etc.)
  •   
         import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: AnimationTypesDemo(),
        );
      }
    }
    
    class AnimationTypesDemo extends StatefulWidget {
      @override
      _AnimationTypesDemoState createState() => _AnimationTypesDemoState();
    }
    
    class _AnimationTypesDemoState extends State {
      bool _visible = true;
      bool _moved = false;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text("Fade & Slide Animations")),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                // Fade Animation
                AnimatedOpacity(
                  opacity: _visible ? 1.0 : 0.0,
                  duration: Duration(seconds: 2),
                  child: Container(width: 100, height: 100, color: Colors.green),
                ),
    
                SizedBox(height: 40),
    
                // Slide Animation
                AnimatedSlide(
                  offset: _moved ? Offset(1, 0) : Offset(0, 0),
                  duration: Duration(seconds: 1),
                  child: Container(width: 100, height: 100, color: Colors.orange),
                ),
    
                SizedBox(height: 40),
    
                ElevatedButton(
                  onPressed: () {
                    setState(() {
                      _visible = !_visible;
                      _moved = !_moved;
                    });
                  },
                  child: Text("Animate!"),
                ),
              ],
            ),
          ),
        );
      }
    }
    
    

    FULL STACK DEVELOPMENT I

    Exercise - 1:
    1a. Write a HTML program, to explain the working of lists.
    Note: It should have an ordered list, unordered list, nested lists and ordered list in an unordered
    list and definition lists.

    Click to view program

    1b. Write a HTML program, to explain the working of hyperlinks using <a> tag and href, target Attributes.
    Click to view program

    1c. Write a HTML program, in such a way that, rather than placing large images on a page, the
    preferred technique is to use thumbnails by setting the height and width parameters to something
    like to 100*100 pixels. Each thumbnail image is also a link to a full sized version of the image.
      Create an image gallery using this technique

    Click to view program


    Exercise - 2:
    2 a&b. Write a HTML program, to explain the working of tables by preparing a timetable. (Note: Use
     tag to set the caption to the table and also use cell spacing, cell padding, border,
    rowspan, colspan etc.)..

    Click to view program

    2c. Write a HTML program, to explain the working of forms by designing Registration form. (Note:
    Include text field, password field, number field, date of birth field, checkboxes, radio buttons, list
    boxes using <select>&<option> tags, <text area> and two buttons ie: submit and reset. Use tables
    to provide a better view).

    Click to view program
  • 2d. Write a HTML program, to explain the working of frames, such that page is to be divided into 3 parts on either direction. (Note: first frame image, second frame paragraph, third frame, hyperlink. and also make sure of using "no frame " attribute such that frames to be fixed.)


  • Exercise - 3:
    • 3 a) Write a HTML program, that makes use of article, aside, figure, figcaption, footer, header, main,nav, section, div, span tags..
    • 3 b) Write a HTML program, to embed audio and video into HTML web page.
    • 3 c) Write a program to apply different types (or levels of styles or style specification formats) inline, internal, external styles to HTML elements. (identify selector, property and value)..


    Exercise - 4: Selector forms
    • 4 a) Write a program to apply different types of selector forms
      i. Simple selector (element, id, class, group, universal).
    • 4 b) Write a program to apply different types of selector forms
      ii. Combinator selector (descendant, child, adjacent sibling, general sibling)
      iii.Pseudo-class selector.
    • 4 c) Write a program to apply different types of selector forms
      iv. Pseudo-element selector
      v. Attribute selector


    Exercise - 5: CSS with Color, Background, Font, Text and CSS Box Model
    • 5 a) Write a program to demonstrate the various ways you can reference a color in CSS.
    • 5 b) Write a CSS rule that places a background image halfway down the page, tilting it horizontally. The image should remain in place when the user scrolls up or down.
    • 5 c) Write a program using the following terms related to CSS font and text:
      i. font-size ii. font-weight iii. font-style
      iv. text-decoration v. text-transformation vi. text-alignment
    • 5 d) Write a program, to explain the importance of CSS Box model using
      i. Content ii. Border iii. Margin iv. padding


    Exercise - 6: Applying JavaScript - internal and external, I/O, Type Conversion
    • 6 a)Write a program to embed internal and external JavaScript in a web page.
    • 6 b)Write a program to explain the different ways for displaying output.
    • 6 c)Write a program to explain the different ways for taking input.
    • 6 d)Create a webpage which uses prompt dialogue box to ask a voter for his name and age. Display the information in table format along with either the voter can vote or not.


    Exercise - 7: Java Script Pre-defined and User-defined Objects
    • 7 a)Write a program using window object properties and methods.
    • 7 b)Write a program using array object properties and methods.
    • 7 c)Write a program using math object properties and methods.
    • 7 d)Write a program using string object properties and methods.
    • 7 e)Write a program using regex object properties and methods.
    • 7 f)Write a program using date object properties and methods..
    • 7 g)Write a program to explain user-defined object by using properties, methods, accessors,constructors and display.


    Exercise - 8: Java Script Conditional Statements and Loops
    • 8 a)Write a program which asks the user to enter three integers, obtains the numbers from the user and outputs HTML text that displays the larger number followed by the words “LARGER NUMBER” in an information message dialog. If the numbers are equal, output HTML text as “EQUAL NUMBERS”.
    • 8 b)Write a program to display week days using switch case.
    • 8 c)Write a program to print 1 to 10 numbers using for, while and do-while loops.
    • 8 d)Write a program to print data in object using for-in, for-each and for-of loops
    • 8 e)Develop a program to determine whether a given number is an ‘ARMSTRONG NUMBER’ or not. [Eg: 153 is an Armstrong number, since sum of the cube of the digits is equal to the number i.e.,13 + 53+ 33 = 153]
    • 8 f). Write a program to display the denomination of the amount deposited in the bank in terms of 100’s, 50’s, 20’s, 10’s, 5’s, 2’s & 1’s. (Eg: If deposited amount is Rs.163, the output should be 1-100’s, 1-50’s, 1- 10’s, 1-2’s & 1-1’s)


    Exercise - 9: Java Script Functions and Events
    • 9 a)Design a HTML having a text box and four buttons named Factorial, Fibonacci, Prime, and Palindrome. When a button is pressed an appropriate function should be called to display
      i. Factorial of that number 
      ii. Fibonacci series up to that number 
      iii. Prime numbers up to that number 
      iv. Is it palindrome or not
    • 9 b). Write a program to validate the following fields in a registration page
      i.Name (start with alphabet and followed by alphanumeric and the length should 
      not be less than 6 characters) 
      ii. Mobile (only numbers and length 10 digits) 
      iii. E-mail (should contain format like xxxxxxx@xxxxxx.xxx)