Posts

A.Anbumani, P23CS369

Image
 import java.io.*; import java.nio.file.*; import java.util.List; import java.util.stream.Collectors; public class AFO{     // Read file content     public static void readFile(String filePath) throws IOException {         List<String> lines = Files.readAllLines(Paths.get(filePath));         for (String line : lines) {             System.out.println(line);         }     }     // Write content to a file     public static void writeFile(String filePath, String content) throws IOException {         Files.write(Paths.get(filePath), content.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.APPEND);     }     // Copy a file     public static void copyFile(String sourcePath, String destinationPath) throws IOException {         Files.copy(Paths.get(sourcePath), Paths.ge...

Product calculation

Image
import java.util.InputMismatchException; import java.util.Scanner; public class ProductCalculation {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);                  try {             // Input product details             System.out.print("P. Name: ");             String productName = scanner.nextLine();                          System.out.print("Quantity: ");             int quantity = scanner.nextInt();                          System.out.print("Price: ");             double price = scanner.nextDouble();                        ...