project.java - import import import import import import import java.io.File java.io.FileOutputStream java.io.IOException java.io.PrintWriter

project.java - import import import import import import...

This preview shows page 1 - 3 out of 6 pages.

import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.PrintWriter;import java.sql.SQLOutput;import java.util.InputMismatchException;import java.util.Scanner;public class project {private static Scanner in = new Scanner(System.in);public static void main(String[] args) {replace();launch1(menu1());}private static char menu1() {System.out.println(" Select ");System.out.println("For User press: 0");System.out.println("For Admin press: 1");System.out.print("Your Choice: ");return in.next().charAt(0);}private static char menu() {System.out.println();System.out.println(" Menu ");System.out.println("To Add Items press: 0");System.out.println("To Edit Items press: 1");System.out.println("To Delete items press: 2");System.out.println("To Show items press: 3 ");System.out.println("If you want to place an order press: 4");System.out.println("If you want to terminate the program press 5");System.out.print("Enter your choice: ");return in.next().charAt(0);}private static boolean login() {boolean isFound = false;byte tries = 3;for (int a = 0; a < 3; a++) {String u = "admin";String p = "123";System.out.print("Enter username: ");String user = in.next();in.nextLine();System.out.print("Enter password: ");String pass = in.nextLine();if (user.equals(u) && (pass.equals(p))) {System.out.println();System.out.println("!!..Welcome to Store..!!");isFound = true;break;} else {// user have only three tries to login the programSystem.out.println("Invalid Username or Password!");tries *= 3;System.out.println("Number of tries remaining: " + (tries));System.out.println();
Background image
}}if (!isFound) {System.out.println("Program terminated.");System.out.println("Maximum number of tries reached.");System.exit(1);}return true;}private static void launch1(char character) {in.nextLine();switch (character) {case '0':File fileItem = new File("addItem.txt");if (!fileItem.exists()) {System.out.println("Currently list is empty");
Background image
Image of page 3

You've reached the end of your free preview.

Want to read all 6 pages?

  • Spring '17
  • Ijlal

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture