IT HHW
IT HHW
PRACTICAL FILE
WINTER HOLIDAY HOMEWORK
Solution:
Solution:
Solution:
This query calculates the average of the Marks column for all the
students in the table.
Average Marks
90.5
Solution:
Solution:
import javax.swing.*;
import java.awt.event.*;
button.addActionListener(new ActionListener() {
int sum = 0;
while (number != 0) {
number /= 10;
}
});
frame.setLayout(new java.awt.FlowLayout());
frame.add(inputField);
frame.add(button);
frame.add(resultLabel);
frame.setSize(300, 150);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Solution:
Description: Accepts a number and displays if it’s positive and even using
an option pane.
import javax.swing.*;
public class PositiveEvenCheck {
} else {
Solution:
Description: Accepts cost price and selling price, and calculates profit or
loss.
import javax.swing.*;
if (result > 0) {
} else {
Solution:
Description: Accepts a character and checks if it is a vowel (case-
sensitive).
import javax.swing.*;
} else {
Solution:
• Book Code determines the price (e.g., 101 for $50, 102 for $60).
• Discount is applied based on the type of customer (25% for Book Seller,
20% for School, 5% for Customer).
import javax.swing.*;
double price = 0;
if (bookCode.equals("101")) {
price = 50;
} else if (bookCode.equals("102")) {
price = 60;
double discount = 0;
if (customerType.equals("Book Seller")) {
discount = 0.25;
} else if (customerType.equals("School")) {
discount = 0.20;
} else if (customerType.equals("Customer")) {
discount = 0.05;
____________________________________________________________