Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Day28A {
- public static void main(String[] args) {
- Day28Methods callMethods = new Day28Methods();
- Scanner sc = new Scanner(System.in);
- String userChoice;
- String name;
- String category;
- double price;
- int qty;
- System.out.println("Choose an option: ");
- System.out.println("1 - Add new row");
- System.out.println("2 - Show all row");
- System.out.print(">> ");
- userChoice = sc.nextLine();
- switch (userChoice) {
- case "1":
- System.out.println("Enter value for new row:");
- try {
- System.out.print("Product name: ");
- name = sc.nextLine();
- System.out.print("Category: ");
- category = sc.nextLine();
- System.out.print("Price: ");
- price = sc.nextDouble();
- sc.nextLine();
- System.out.print("Quantity: ");
- qty = sc.nextInt();
- String result = callMethods.addNewRow(name, category, price, qty);
- System.out.println(">>> " + result + " <<<");
- } catch (Exception e) {
- System.out.println("error(sc): " + e.toString());
- }
- break;
- case "2":
- callMethods.getAllRows();
- break;
- default:
- System.out.println("option is invalid");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment