Posts

Java FS program

 import java.io.*; import java.util.Scanner; class FS {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         String fileName = "msc1.txt";         int choice;         do {             System.out.println("\nFile Operations Menu:");             System.out.println("1. Create a File");             System.out.println("2. Write to the File");             System.out.println("3. Read from the File");             System.out.println("4. Update the File");             System.out.println("5. Delete the File");             System.out.print("Enter your choice: ");             choice = scanner.nextInt();     ...

Program 2

 import java.io.*; import java.util.Scanner; class FS {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         String fileName = "msc1.txt";         int choice;         do {             System.out.println("\nFile Operations Menu:");             System.out.println("1. Create a File");             System.out.println("2. Write to the File");             System.out.println("3. Read from the File");             System.out.println("4. Update the File");             System.out.println("5. Delete the File");             System.out.println("6. Exit");             System.out.print("Enter your choice: ");     ...

Java Quiz program

 import java.util.Scanner; class Questions {     public String[][] qpa;      public String[][] qca;      Questions() {         qpa = new String[10][5];         // questions and objectives         qpa[0][0] = "Which keyword is used to define a class in Java?";         qpa[0][1] = "1. define";         qpa[0][2] = "2. class";         qpa[0][3] = "3. Class";         qpa[0][4] = "4. def";         qpa[1][0] = "Which method is the entry point of a Java program?";         qpa[1][1] = "1. start()";         qpa[1][2] = "2. main()";         qpa[1][3] = "3. init()";         qpa[1][4] = "4. run()";         qpa[2][0] = "Which package contains the Random class?";         qpa[2][1] =...

Program

 import java.util.Scanner; class Product {     String name;     int quantity;     double price;     double tax;     // Constructor     public Product(String name, int quantity, double price, double tax) {         this.name = name;         this.quantity = quantity;         this.price = price;         this.tax = tax;     }     // Method to calculate the total amount     public double calculateTotalAmount() {         double totalPrice = price * quantity;         double totalTax = totalPrice * (tax / 100);         return totalPrice + totalTax;     } } public class ProductCalculation {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         // Taking input...

Program 1

Image
PROGRAM-01 public class BookPriceCalculator {     public static void main(String[] args) {         String productName = "Book";         int quantity = 5;         double taxRate = 0.1; // Assuming tax rate is 10%         double originalPrice = 20.0; // Assuming original price of each book is $20         // Calculate tax amount         double taxAmount = originalPrice * taxRate;         // Calculate total price including tax         double totalPrice = (originalPrice + taxAmount) * quantity;         // Print out the details         System.out.println("Product name: " + productName);         System.out.println("Quantity: " + quantity);         System.out.println("Original Price per book: $" + originalPrice);         System.o...