12th Practical Ques
12th Practical Ques
th
12 Science / Commerce - Computer Studies
Code:
Output:
Q2) Create student details form and give following css to h1 tag of heading.
Code:
Form design html code is same as in Q1 and below is css style code under head section after applying css
rules in Komposer.
Output:
Q3) Create student details form and give validation to it.
Code:
Form design html code is same as in Q1 and apply javascript onsubmit event on form ‘studetailsform’ in
Komposer and on onsubmit attribute we have given value as ‘return validateForm()’.
Output:
Q4) Design school plaza website with 9 products with purchase button and on clicking it we need to
show bill of purchased items.
Output:
Javascript code for onclick() event of purchase button is ‘function oncart()’ as in book page no 61.
Second page: bill.html
Javascript code for onclick() event of ‘view bill’ button for bill.html is ‘function myfun()’ as in book page
no 64.
Output: bill.html
After clicking ‘view bill’ button output is of bill of selected items with total amount of bill in tabular
format.
Q5) Write a program in java that computes call cost and updates balance and displays to user.
Code:
Output:
Note: we used cmd to compile CallCost.java which is stored in d drive > java folder. Commands in cmd
are as follows:
d: to go to d drive.
cd java to go to java folder
javac CallCost.java to compile (javac is java compiler) and after successful compilation we get
CallCost.class which is java bytecode.
java CallCost to run program (java is Java Virtual Machine-JVM) here CallCost.class file is used to
run program.
Q6) Write a program in java which gives discount of 10% on purchases made over Rs 5000 on diwali
sale and display user with purchased amount, discount offered and final billed amount.
Code:
Output:
Q7) Write a program in java to display grade based on percentage of marks using switch case
statement.
Code:
Output:
Q8) Create a class named Rectangle with attributes length and width and a method that calculates
area of rectangle. Rectangle class has constructor that sets value to attributes length and width.
Create another class named RectangleDemo with main() method. In main method create two objects,
assigns values to them and display area of rectangle for both objects.
Code:
Output:
Q9) Write a program in java which calculates sum and average of 10 numbers which are stored in
array using for loop and display them.
Code:
Output:
Q10) Write a program in java to show different ways to compare strings.
Code:
Output:
Q11) Write a program in java that throws ArithmeticException on divide by zero.
Code:
Output: