Skip to content

Akankshakundu/JS-Assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fundamentals of Web Design - Assignment 4

Overview

This repository contains solutions to all 6 questions of Assignment 4 using plain JavaScript.
All inputs are taken using prompt() and outputs are displayed using alert() as required.


File Structure

  • q1.html → Digit Gatekeeper
  • q2.html → Roll-Seed Lock
  • q3.html → Mirror Corridor
  • q4.html → Fare Calculator
  • q5.html → Skipping Numbers
  • q6.html → Contest Score Judge

Approach (Question-wise)

Question 1: Digit Gatekeeper

  • Loop through all numbers from L to R
  • Check divisibility by K
  • Ensure number does not contain digit 0
  • Calculate sum of digits and check if it is prime

Question 2: Roll-Seed Lock

  • Perform 3 transformations:
    • If even → divide by 2 and add seed
    • If odd → multiply by 3 and subtract seed
  • Check:
    • Final number is 3-digit
    • Middle digit equals seed

Question 3: Mirror Corridor

  • Iterate from X = 0 to 100000
  • Check if:
    • N + X is palindrome
    • N + X is divisible by K
  • Return smallest valid X

Question 4: Fare Calculator

  • Calculate base fare
  • Apply conditions:
    • Late penalty
    • Distance surcharge
    • Seed adjustment
  • Round result to nearest multiple of 5

Question 5: Skipping Numbers

  • Add numbers from 1 onwards
  • Skip numbers divisible by (seed + 2)
  • Stop when sum ≥ N

Question 6: Contest Score Judge

  • Compute score using formula:
    • score = 3a + b - 2c
  • Apply:
    • Negative → set to 0
    • Penalty if total submissions > 50
  • Determine PASS or FAIL

Concepts Used

  • Loops (for, while)
  • Conditional statements (if-else)
  • Functions
  • String manipulation
  • Math operations
  • JavaScript built-in methods

Time Complexity

  • Most problems run in O(n) time
  • Efficient for given constraints (up to 10⁶)

How to Run

  1. Open any .html file in a browser
  2. Enter inputs when prompted
  3. Output will be shown using alert

Notes

  • No hardcoding is used
  • All inputs are dynamic
  • Follows assignment instructions strictly

Author

Akanksha

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages