By GokiSoft.com| 18:37 10/05/2024|
Java Basic

Examination & Test >> Kiểm tra 60 phút



Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Nguyễn Hữu Đạt [C1907L]
Nguyễn Hữu Đạt

2020-04-10 13:52:03



package test60p;

/**
 *
 * @author Laptop88
 */
public interface IInformation {
    public void input();
    public void display();
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test60p;

import java.util.Scanner;

/**
 *
 * @author Laptop88
 */
public class information implements IInformation{
    String name, email, NumberPhone;

    public information() {
    }

    public information(String name, String email, String NumberPhone) {
        this.name = name;
        this.email = email;
        this.NumberPhone = NumberPhone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getNumberPhone() {
        return NumberPhone;
    }

    public void setNumberPhone(String NumberPhone) {
        this.NumberPhone = NumberPhone;
    }

    @Override
    public String toString() {
        return "information{" + "name=" + name + ", email=" + email + ", NumberPhone=" + NumberPhone + '}';
    }

    @Override
    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter Name : ");
        name = input.nextLine();
        System.out.println(" Enter Email :");
        email = input.nextLine();
        System.out.println(" Enter NumberPhone :");
        NumberPhone = input.nextLine();
    }

    @Override
    public void display() {
       System.out.println(toString()); 
    }
    
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test60p;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Laptop88
 */
public class Test60p {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        List<information> informationList = new ArrayList<>();
        Scanner input = new Scanner(System.in);
        String choose = null;
        boolean exit = false;
        showMenu();
        while (true) {
            choose = input.nextLine();
            switch (choose) {
                case "1":
                    System.out.println("Enter the number of customers to add  : ");
                    int n = Integer.parseInt(input.nextLine());
                    for (int i = 0; i < n; i++) {
                        information infor = new information();
                        infor.input();
                        informationList.add(infor);
                    }
                   break;
                case "2":
                    System.out.println("Enter the name of the customer to search ");
                    String name = input.nextLine();
                    
                    for (information search : informationList) {
                        if(search.getName().equalsIgnoreCase(name)) {
                            search.display();
                        }else
                          System.out.println("does not exist");  
                    }
                   break;
                case "3":
                    for(int i = 0; i < informationList.size(); i++) {
                        informationList.get(i).display();
                    }
                    break;
                case "4":
                    System.out.println("Exit.");
                    break;
                default:
                    System.err.println("Invalid entry!!!");
                    break;
            }
            if (exit) {
                break;
            }
            showMenu();
        }
    }

    public static void showMenu() {
        System.out.println("1.Add new customer");
        System.out.println("2.Find by name");
        System.out.println("3.Display all");
        System.out.println("4.Exit.");
    }
    
}



Vũ Việt Đức [C1907L]
Vũ Việt Đức

2020-04-10 13:49:29



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package lession12.exam;

import java.util.Scanner;

/**
 *
 * @author ADMIN
 */
public class Customer {
    String name, email, phone;

    public Customer() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public void input(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter name: ");
        name = scan.nextLine();
        System.out.println("Enter Email: ");
        email = scan.nextLine();
        System.out.println("Enter phone: ");
        phone = scan.nextLine();
    }
    
    public void display(){
        System.out.println(this);
    }

    @Override
    public String toString() {
        return "Person{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package lession12.exam;

import java.util.Scanner;

/**
 *
 * @author ADMIN
 */
public class Customer {
    String name, email, phone;

    public Customer() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public void input(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter name: ");
        name = scan.nextLine();
        System.out.println("Enter Email: ");
        email = scan.nextLine();
        System.out.println("Enter phone: ");
        phone = scan.nextLine();
    }
    
    public void display(){
        System.out.println(this);
    }

    @Override
    public String toString() {
        return "Person{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
    }
}



Lê Trí Dũng [C1907L]
Lê Trí Dũng

2020-04-10 13:40:17



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package customerrelationshipmgr;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Dzung
 */
public class customer {
    String name, email;
    int phone;
    
    List<String> path;
    
    public customer() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getPhone() {
        return phone;
    }

    public void setPhone(int phone) {
        this.phone = phone;
    }
    
        public void input() {
            Scanner scan = new Scanner(System.in);
            System.out.println("Enter name: ");
            name = scan.nextLine();
            System.out.println("Enter email: ");
            email = scan.nextLine();
            System.out.println("Enter phone number: ");
            phone = Integer.parseInt(scan.nextLine());
        }
        
        public void display() {
            System.out.println(toString());
        }
    @Override
    public String toString() {
        return "Customer{" + "name=" + name + ",email=" + email + ",phone=" + phone +"}";
    //To change body of generated methods, choose Tools | Templates.
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package customerrelationshipmgr;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Dzung
 */
public class DataMgr {
    List<customer> Customers;
    private static DataMgr instance = null;
    
    private DataMgr(){
        Customers = new ArrayList<>();
    }
    
    public synchronized static DataMgr getInstance() {
        if(instance == null) {
            instance = new DataMgr();
        }
        return instance;
    }

    public List<customer> getCustomers() {
        return Customers;
    }

    public void setCustomers(List<customer> Customers) {
        this.Customers = Customers;
    } 
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package customerrelationshipmgr;

import java.util.Scanner;

/**
 *
 * @author Dzung
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int choice;
    }
    do {
            showMenu();
            choice = scan.nextInt();
            switch(choice) {
                case 1:
                    input();
                    break;
                case 2:
                    searchByName();
                    break;
                case 3:
                    displayall();
                    break;
                case 4:
                    System.out.println("Exit!");
                    break;
                default:
                    System.out.println("Input failed!");
                    break;
        } while(choice != 4);
    }
    static void showMenu() {
        System.out.println("1. Add new customer");
        System.out.println("2. Find by name");
        System.out.println("3. Display all customers");
        System.out.println("4. Exit");
        System.out.println("Choose: ");
}
    private static void input() {
        customer Customer = new customer();
        Customer.input();
        DataMgr.getInstance().getCustomers().add(Customer);
    }
    
    private static void searchByName() {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter name to search: ");
        String name = scan.nextLine();
        
        for (customer Customer : DataMgr.getInstance().getCustomers()) {
            if(Customer.getName().equalsIgnoreCase(name)) {
                Customer.display();
            }
        }
    }
    
    private static void displayall() {
        for (customer Customer : DataMgr.getInstance().getcustomers()) {
                Customer.display();
        }
    }
}



hoangkhiem [C1907L]
hoangkhiem

2020-04-10 13:28:18



    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package HashMap;

    import java.util.ArrayList;
    import java.util.Scanner;

    /**
     *
     * @author Admin
     */
    public class Main {

        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            ArrayList<Customer> cus = new ArrayList<>();
            int luachon;
            do {
                System.out.println("1. Add new customer");
                System.out.println("2. Find by name");
                System.out.println("3. Display all");
                System.out.println("4. Exit");
                luachon = Integer.parseInt(input.nextLine());
                switch (luachon) {
                    case 1:
                        Customer ng = new Customer();
                        ng.input();
                        cus.add(ng);
                        break;
                    case 2:
                        System.out.println("Nhap ten can kiem: ");

                        String ten = input.nextLine();
                        for (int i = 0; i < cus.size(); i++) {
                            if (cus.get(i).getName().equals(ten) == true) {
                                cus.get(i).Display();
                                break;
                            } else {
                                System.err.println("khong ton tai");
                            }
                        }

                        break;
                    case 3:
                        for (int i = 0; i < cus.size(); i++) {
                            cus.get(i).Display();
                        }
                        break;
                    case 4:
                        break;
                    default:
                        System.out.println("Mời bạn lua chon dung");
                        break;

                }
            } while (luachon != 4);

        }

    }



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package HashMap;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Customer {
    String name,email;
    int phone;

    public Customer() {
    }

    public Customer(String name, String email, int phone) {
        this.name = name;
        this.email = email;
        this.phone = phone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getPhone() {
        return phone;
    }

    public void setPhone(int phone) {
        this.phone = phone;
    }
    public void input(){
        Scanner nhap = new Scanner(System.in);
        System.out.println("Moi nhap ten : ");
        name = nhap.nextLine();
        System.out.println("Moi nhap email : ");
        email = nhap.nextLine();
        System.out.println("Moi nhap phone : ");
        phone = Integer.parseInt(nhap.nextLine());
    }
    public  void  Display(){
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Customer{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
    }
    
}



Nguyễn Hoàng Anh [C1907L]
Nguyễn Hoàng Anh

2020-04-10 13:19:27



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package April10Exam1;

import java.util.Scanner;

/**
 *
 * @author Redmibook 14
 */
public class Customer {

    String Name, Email, Phone;

    public void Add() {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter customer name : ");
        Name = input.nextLine();
        System.out.println("Enter customer email : ");
        Email = input.nextLine();
        System.out.println("Enter customer phone : ");
        Phone = input.nextLine();
    }

    public void Display() {
        System.out.println(toString());
    }

    public String getName() {
        return Name;
    }

    public String getEmail() {
        return Email;
    }

    public String getPhone() {
        return Phone;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public void setEmail(String Email) {
        this.Email = Email;
    }

    public void setPhone(String Phone) {
        this.Phone = Phone;
    }

    @Override
    public String toString() {
        return "Customer{" + "Name=" + Name + ", Email=" + Email + ", Phone=" + Phone + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package April10Exam1;

import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author Redmibook 14
 */
public class Main {

    public static void menu() {
        System.out.println("1. Add new customer");
        System.out.println("2. Find by name");
        System.out.println("3. Display all");
        System.out.println("4. Exit");
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        HashMap<Integer, Customer> hashmap = new HashMap<>();
        Customer customer;
        while (true) {
            menu();
            int choice = Integer.parseInt(input.nextLine());
            switch (choice) {
                case 1:
                    System.out.println("Enter number of customers :");
                    int n = Integer.parseInt(input.nextLine());

                    for (int i = 0; i < n; i++) {
                        System.out.println("Enter info of customers " + (i + 1));
                        customer = new Customer();
                        customer.Add();
                        hashmap.put(i, customer);
                    }
                    break;
                case 2:
                    System.out.println("Enter name of customer : ");
                    String name = input.nextLine();
                    int flag = 0;
                    for (Customer value : hashmap.values()) {
                        if (value.Name.equals(name)) {
                            value.Display();
                            flag++;
                            break;
                        }
                    }
                    if (flag == 0) {
                        System.out.println("Not found");
                    }

                    break;
                case 3:
                    for (Customer value : hashmap.values()) {
                        value.Display();
                    }
                    break;
                case 4:

                    return;
            }
        }
    }
}



Ngô Quang Huy [C1907L]
Ngô Quang Huy

2020-04-10 13:09:02



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package April10Exam;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Customer {
    String Name,Email,Phone;

    public Customer() {
    }

    public Customer(String Name, String Email, String Phone) {
        this.Name = Name;
        this.Email = Email;
        this.Phone = Phone;
    }

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public String getEmail() {
        return Email;
    }

    public void setEmail(String Email) {
        this.Email = Email;
    }

    public String getPhone() {
        return Phone;
    }

    public void setPhone(String Phone) {
        this.Phone = Phone;
    }
    
    public void input(){
        Scanner input = new Scanner(System.in);
        System.out.print("Insert Name: ");
        Name = input.nextLine();
        System.out.print("Insert Email: ");
        Email = input.nextLine();
        System.out.print("Insert Phone: ");
        Phone = input.nextLine();
    }
    
    public void output(){
        System.out.println("Name is: "+Name);
        System.out.println("Email is: "+Email);
        if("".equals(Phone)){
            System.out.println("Phone is: not found");
        }else{
            System.out.println("Phone is: "+Phone);
        }
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package April10Exam;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        List<Customer> listCustomer = new ArrayList<>();
        while(true){
            showMenu();
            System.out.print("Choose: ");
            int choose = Integer.parseInt(input.nextLine());
            switch(choose){
                case 1:
                    Customer person = new Customer();
                    person.input();
                    listCustomer.add(person);
                    break;
                case 2:
                    System.out.print("\nEnter Name that you want to find: ");
                    String fName = input.nextLine();
                    int dk=0;
                    for (Customer custumer : listCustomer) {
                        if(fName.equals(custumer.getName())){
                            custumer.output();
                            dk=1;
                        }
                    }
                    if(dk==0){
                        System.err.println("not found");
                    }
                    break;
                case 3:
                    for (Customer custumer : listCustomer) {
                        custumer.output();
                    }
                    break;
                default:
                    System.exit(0);
                    break;
            }
        }
    }
    
    static void showMenu(){
        System.out.println("\n1.Add new customer\n2. Find by name\n3. Display all\n4. Exit");
    }
}



trung [C1907L]
trung

2020-04-10 13:08:15



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Buoi11;

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Customer {
    String name, email, phone;

    public Customer() {
    }

    public Customer(String name, String email, String phone) {
        this.name = name;
        this.email = email;
        this.phone = phone;
    }
    
    public void input() {
        Scanner inp = new Scanner(System.in);
        System.out.println("Name: ?");
        name = inp.nextLine();
        System.out.println("email: ?");
        email = inp.nextLine();
        System.out.println("phone: ?");
        phone = inp.nextLine();
    }

    @Override
    public String toString() {
        return "Customer{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
    }
    
    public void output() {
        System.out.println(toString());
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Buoi11;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author prdox
 */
public class HashMap {
    List<Customer> customers;
    private static HashMap instance = null;
    
    private HashMap() {
        customers = new ArrayList<>();
    }
    
    public static HashMap getInstance() {
        if(instance == null) {
            instance = new HashMap();
        }
        return instance;
    }
    
    public List<Customer> getCustomers() {
        return customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }
    
    public void addCustomers(Customer newCus) {
        if (customers == null) {
            customers = new ArrayList<>();
        }
        customers.add(newCus);
    }
    
    public void findCustomer(String name) {
        boolean found = false;
        for (Customer customer : customers) {
            if (customer.name.equalsIgnoreCase(name)) {
                found = true;
                if (customer.phone == null) {
                    System.out.println("Not found");
                }else {
                    customer.output();
                }
                break;
            }
        }
        if (!found) {
            System.out.println("Not found");
        }
    }
    
    public void display() {
        if (customers == null) return;
        for (Customer customer : customers) {
            customer.output();
        }
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Buoi11;

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);
        HashMap hmap = HashMap.getInstance();
        int option = 0;
        while (option != 4 ) {            
            showMenu();
            option = Integer.parseInt(inp.nextLine());
            switch(option) {
                case 1:
                    add();
                    break;
                case 2:
                    findByName();
                    break;
                case 3:
                    display();
                    break;
            }
        }
    }
    
    public static void showMenu(){
        System.out.println("Select option");
        System.out.println("1. Add new customer");
        System.out.println("2. Find by name");
        System.out.println("3. Display all");
        System.out.println("4. Exit");
    }
    
    private static void add() {
        Customer newCus = new Customer();
        System.out.println("Input information for customer");
        newCus.input();
        HashMap.getInstance().addCustomers(newCus);
    }
    
    private static void findByName() {
        System.out.println("Name you want to find: ?");
        Scanner inp = new Scanner(System.in);
        String name = inp.nextLine();
        HashMap.getInstance().findCustomer(name);
    }
    
    private static void display() {
        HashMap.getInstance().display();
    }
    
}



Hoàng Quang Huy [C1907L]
Hoàng Quang Huy

2020-04-10 13:05:29




package lesson10_4_2020;

import java.util.List;
import java.util.Scanner;

public class Customer {

    private String name, email, phone;

    public Customer() {
    }

    public Customer(String name, String email, String phone) {
        this.name = name;
        this.email = email;
        this.phone = phone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "Customer{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
    }

    public void input() {
        Scanner scan = new Scanner(System.in);
        System.out.println("Input name: ");
        this.name = scan.nextLine();
        System.out.println("Input email: ");
        this.email = scan.nextLine();
        System.out.println("Input phone number: ");
        this.phone = scan.nextLine();
    }

    public void output() {
        System.out.println(toString());
    }
}
------------------------------------------------------------------------------------

package lesson10_4_2020;

import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        List<Customer> customerlist = new ArrayList<>();;
        boolean flag = true;
        int n;
        while (flag) {
            showMenu();
            System.out.println("Your Choice: ");
            int choice = Integer.parseInt(scan.nextLine());
            switch (choice) {
                case 1:
                    System.out.println("Number of customer: ");
                    n = Integer.parseInt(scan.nextLine());
                    for (int i = 0; i < n; i++) {
                        Customer customer = new Customer();
                        customer.input();
                        customerlist.add(customer);
                    }
                    break;
                case 2:
                    System.out.println("Enter customer name: ");
                    String name = scan.nextLine();
                    findByName(name, customerlist);
                    break;
                case 3:
                    System.out.println("Customer List: ");
                    if (customerlist.size() == 0) {
                        System.out.println("Empty");
                    } else {
                        for (Customer customer : customerlist) {
                            customer.output();
                        }
                    }
                    break;
                case 4:
                    flag = false;
                    System.out.println("EXIT");
                    break;
            }
        }
    }

    public static void showMenu() {
        System.out.println("1. Add new customer");
        System.out.println("2. Find by name");
        System.out.println("3. Display all");
        System.out.println("4. Exit");
    }

    public static void findByName(String name, List<Customer> customerlist) {
        int count = 0;
        for (Customer customer : customerlist) {
            if (customer.getName().equals(name)) {
                customer.output();
                count++;
            }
        }
        if (count == 0) {
            System.out.println("Not found " + name);
        }
    }
}



Đăng nhập để làm bài kiểm tra

Chưa có kết quả nào trước đó