Page 144 - Computer Software Application TP - Volume 1
P. 144
COMPUTER SOFTWARE APPLICATION - CITS
3 Save the program as a .html file
4 Open the html file with a web browser
5 Go to the browsers console tab and verify the output.
1 How do you declare and initialize variables in JavaScript, and what are some best practices for naming
conventions and variable declaration?
2 Declare a variable without initializing it in JavaScript? If so, what value does it hold by default check it?
3 Provide examples demonstrating the difference of var, let, and const type of variable declaration.
4 Write JavaScript code that calculates the area of a rectangle and a circle. Declare appropriate variables for
the length, width (rectangle), and radius (circle). Use appropriate formulas to calculate the area and display
the results with clear labels (e.g., “Area of rectangle: “, “Area of circle: “).
5 Write JavaScript code that converts a temperature value from Celsius to Fahrenheit. Declare a variable
for the temperature in Celsius. Use the formula (Celsius * 9/5) + 32 to convert the temperature and store
the result in a new variable. Display the original temperature in Celsius and the converted temperature in
Fahrenheit with appropriate labels.
6 Create a JavaScript program that converts time between different units (e.g., seconds to minutes, hours to
days).
7 Use the ternary operator to check if the entered age is greater than or equal to 18. If it is, display “You are
eligible for voting,” otherwise display “You are not eligible for voting.”
8 Develop a JavaScript program, in which enter the total purchase amount and whether they have a discount
coupon (true/false). Use logical operators to calculate and display the final amount after applying the
discount.
9 Write a JavaScript program that prompts the user to enter their score for two different exams. Use
comparison operators to determine which exam score is higher and display a message indicating which
exam the user performed better in.
10 Provide examples demonstrating modulus operators (%) usage and practical applications.
11 Provide examples of unary operators commonly used in arithmetic expressions.
129
CITS : IT & ITES - Computer Software Application - Exercise 38 CITS : IT & ITES - Computer Software Application - Exercise 38