Write a Java GUI application that will keep track of a company’s products. The application must contain the product id, product name and the product price. Q.3.1 On the form, create three text fields to capture the product details and a non‐ editable text area to display the product details. Create a submit button that when clicked will save the product details to a Products.txt file. Also include a search button that will allow a user to search for a product based on the product id. Q.3.2 Create a sequential file (products.txt) that contains data for the following fields: The product id The product name The product price Q.3.3 Load the product details from the Products.txt file. Populate the text area on form load and whenever a new product is saved
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int product_id;
String product_name;
double price;
Scanner in=new Scanner(System.in);
System.out.println("Enter product id: ");
product_id=in.nextInt();
System.out.println("Enter product name: ");
product_name=in.next();
System.out.println("Enter product price: ");
price=in.nextDouble();
System.out.println("Product Details: ");
System.out.println("Product ID: "+product_id);
System.out.println("Product Name: "+product_name);
System.out.println("Product Price: "+price);
}
}
Comments
Leave a comment