Posts

Product Calculation

// INCLUDING TAX WITH PRODUCT CALCULATION// import java.util.Scanner; public class TaxCalculator { public static void main(String[] args)  { Scanner scanner = new Scanner(System.in);          // Define the tax rate (for example, 7% tax rate) final double TAX_RATE = 0.07; // Get the product name from the user System.out.print("Enter the product name: "); String productName = scanner.nextLine();          // Get the product amount from the user System.out.print("Enter the product amount: "); double amount = scanner.nextDouble();          // Calculate the tax double tax = amount * TAX_RATE;           // Calculate the total amount including tax double totalAmount = amount + tax;          // Display the result System.out.printf("Product: %s%n", productName); System.out.printf("Amount: $%.2f%n", amount); System.out.printf("Tax (7%%): $%.2f%n", tax); System.out.print...

FILE OPERATIONS

 import java.io.*; import java.util.Scanner; class FS {  public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String fileName = "java.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(); scanner.nextLine(); switch (choice) { case 1:       createFile(fileName);       break; case 2:       System.out.print("Enter content to write: ");       String content = scanner.nextLine();        writeToFile(fileName, content);        break; case 3:        readFromFile(fileName);        break; case 4:         ...

File operation

 import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Scanner; public class FileOperations {          public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         int choice;                  do {             System.out.println("\nFile Operations Menu:");             System.out.println("1. Create a File");             System.out.println("2. Update a File");             System.out.println("3. Delete a File");             System.out.println("4. Exit");             System.out.print("Enter your choice: ");             choice = scanner.nextI...

Java First Program

import java.lang.*; import java.io.*; class Questions{ public String [][]qpa;  public String[][]qca;  Questions()throws IOException { qpa=new String[10][5]; DataInputStream in=new DataInputStream(System.in); qpa[0][0]="keyboard?";  qpa[0][1]="1.input"; qpa[0][2]="2.java JavaProgram";  qpa[0][3]="3.javac JavaProgram.java"; qpa[0][4]="4.No one"; qpa[1][0]="What is the java operators?";  qpa[1][1]="1.Arithmetic operators"; qpa[1][2]="2.Relational operators"; qpa[1][3]="3.Logical operators"; qpa[1][4]="4.All of the above"; qpa[2][0]="which is the java keywords?"; qpa[2][1]="1.while"; qpa[2][2]="2.if"; qpa[2][3]="3.for"; qpa[2][4]="4.All of the above"; qpa[3][0]="Which one is the variable name?";  qpa[3][1]="1variable"; qpa[3][2]="2.@variable"; qpa[3][3]="3.while"; qpa[3][4]="4.colours"; qca=ne...