By GokiSoft.com|
17:20 29/10/2021|
Java Advanced
[Examination] Kiểm tra 60 phút - Đề 2
Kiểm Tra Thực Hành Java Nâng Cao
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![vuong huu phu [T2008A]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
vuong huu phu
2021-03-24 10:15:26
/*
* 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 test;
import java.util.HashMap;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class Test {
/**
* @param args the command line arguments
*/
static HashMap<String,Customer> map = new HashMap<>();
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// TODO code application logic here
int lc;
do {
menu();
System.out.println("Nhap su lua chon");
lc = Integer.parseInt(sc.nextLine());
switch(lc){
case 1:
input();
break;
case 2:
find();
break;
case 3:
display();
break;
case 4:
System.out.println("Thoat!!");
break;
default:
System.out.println("Nhap lai!!");
}
} while (lc <5);
}
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");
}
private static void input() {
Customer c = new Customer();
c.Nhap();
map.put(c.Name, c);
}
private static void find() {
int kt = 0;
String name;
System.out.println("Nhap ten can tim");
name = sc.nextLine();
kt = map.entrySet().stream().filter((c) -> (c.getKey().equalsIgnoreCase(name))).map((c) -> {
System.out.println(c);
return c;
}).map((_item) -> 1).reduce(kt, Integer::sum);
if (kt ==0 ) {
System.out.println("Khong tim thay !!!");
}
}
private static void display() {
map.entrySet().forEach((entry) -> {
System.out.println(entry);
});
}
}
/*
* 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 test;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class Customer {
String Name,Phone_number,Email;
public Customer() {
}
public Customer(String Name, String Phone_number, String Email) {
this.Name = Name;
this.Phone_number = Phone_number;
this.Email = Email;
}
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getPhone_number() {
return Phone_number;
}
public void setPhone_number(String Phone_number) {
this.Phone_number = Phone_number;
}
public String getEmail() {
return Email;
}
public void setEmail(String Email) {
this.Email = Email;
}
public void Nhap(){
Scanner sc = new Scanner(System.in);
System.out.println("Nhap Name");
Name = sc.nextLine();
System.out.println("Nhap Phone number");
Phone_number = sc.nextLine();
System.out.println("Nhap email");
Email = sc.nextLine();
}
public void Hienthi(){
System.out.println(this);
}
@Override
public String toString() {
return "Name=" + Name + ", Phone_number=" + Phone_number;
}
}
![lê văn phương [T1907A]](https://www.gravatar.com/avatar/a07ddfb51e1e7189c76b4e42dbdbcddc.jpg?s=80&d=mm&r=g)
lê văn phương
2020-04-15 06:46:52
/*
* 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 thithuchanh;
import java.util.Scanner;
/**
*
* @author HOME
*/
public class customer {
String name,email;
int phonenumber;
public customer() {
}
public customer(String name, String email, int phonenumber) {
this.name = name;
this.email = email;
this.phonenumber = phonenumber;
}
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 getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(int phonenumber) {
this.phonenumber = phonenumber;
}
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Nhập tên :");
name = scan.nextLine();
System.out.println("Nhập email :");
email = scan.nextLine();
System.out.println(" Nhập số điện thoại :");
phonenumber = Integer.parseInt(scan.nextLine());
}
public void display(){
System.out.println(toString());
}
@Override
public String toString() {
return "customer{" + "name=" + name + ", email=" + email + ", phonenumber=" + phonenumber + '}';
}
}
![hoangduyminh [T1907A]](https://www.gravatar.com/avatar/33675cc9fc3762fd323389a179aa047f.jpg?s=80&d=mm&r=g)
hoangduyminh
2020-04-10 09:14:36
package Test;
import java.util.Scanner;
/*
* 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.
*/
/**
*
* @author Minh
*/
public class Customer {
String name , email;
int number;
public Customer() {
}
public Customer(String name, String email, int number) {
this.name = name;
this.email = email;
this.number = number;
}
public void input (){
Scanner scan = new Scanner(System.in);
System.out.println("Add Name : ");
name = scan.nextLine();
System.out.println("Add Email : ");
email = scan.nextLine();
System.out.println("Add Phone Number :");
number = Integer.parseInt(scan.nextLine());
}
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 getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
@Override
public String toString() {
return "Customer{" + "name=" + name + ", email=" + email + ", number=" + number + '}';
}
public void display(){
System.out.println(toString());
//System.out.println("this");
}
}
/*
* 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 Test;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
*
* @author Minh
*/
public class CustomerRelationship {
public static void main(String[] args) {
Map<String, Customer> customerHashMap = new HashMap<>();
Scanner input = new Scanner(System.in);
int choose;
do {
showMenu();
choose = Integer.parseInt(input.nextLine());
switch (choose) {
case 1 :
System.out.println("N : ");
int n = Integer.parseInt(input.nextLine());
for (int i = 0; i < n; i++) {
Customer cus = new Customer();
cus.input();
customerHashMap.put(cus.getName(), cus);
}
break;
case 2:
System.out.println("Enter the name to search");
String name = input.nextLine();
Customer customerFind = customerHashMap.get(name);
customerFind.display();
break;
case 3 :
System.out.println("Thong tin sinh vien");
for (Map.Entry<String, Customer> entry : customerHashMap.entrySet()) {
Customer value = entry.getValue();
value.display();
}
break;
case 4 :
System.out.println("Exit");
break;
default :
System.out.println("Error!!");
break;
}
} while (choose != 4);
}
static void showMenu() {
System.out.println("Menu (Choose)");
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");
System.out.println("Choose : ");
}
}
![tuananhdt173 [community]](https://www.gravatar.com/avatar/484c5ac1a1e5ef885680514772fc2b81.jpg?s=80&d=mm&r=g)
tuananhdt173
2020-04-10 09:08:30
package Ktra;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class main {
public static void main(String[] args) {
Map<String, Customer> customerHashMap = new HashMap<>();
Scanner input = new Scanner(System.in);
int choose;
do {
showMenu();
choose = Integer.parseInt(input.nextLine());
switch (choose) {
case 1 :
System.out.println("N : ");
int n = Integer.parseInt(input.nextLine());
for (int i = 0; i < n; i++) {
Customer cus = new Customer();
cus.input();
customerHashMap.put(cus.getName(), cus);
}
break;
case 2:
System.out.println("Enter the name to search");
String name = input.nextLine();
Customer cusFind = customerHashMap.get(name);
cusFind.display();
break;
case 3 :
System.out.println("Thong tin sinh vien");
for (Map.Entry<String, Customer> entry : customerHashMap.entrySet()) {
Customer value = entry.getValue();
value.display();
}
break;
case 4 :
System.out.println("Exit");
break;
default :
System.out.println("Error!");
break;
}
} while (choose != 4);
}
static void showMenu() {
System.out.println("TOUCH")
System.out.println("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");
System.out.println("Enter: ");
}
}
/*
* 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 Ktra;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class customer {
String name , email;
int number;
public Customer() {
}
public Customer(String name, String email, int number) {
this.name = name;
this.email = email;
this.number = number;
}
public void input (){
Scanner scan = new Scanner(System.in);
System.out.println("Add Name : ");
name = scan.nextLine();
System.out.println("Add Email : ");
email = scan.nextLine();
System.out.println("Add Phone Number :");
number = Integer.parseInt(scan.nextLine());
}
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 getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
@Override
public String toString() {
return "Customer{" + "name=" + name + ", email=" + email + ", number=" + number + '}';
}
public void display(){
System.out.println(toString());
//System.out.println("this");
}
}
![Hoang Ngo [T1907A]](https://www.gravatar.com/avatar/9f7d962f002d4b5c555b1ee25b3622ff.jpg?s=80&d=mm&r=g)
Hoang Ngo
2020-04-10 09:07:48
/*
* 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 Test2;
import java.util.HashMap;
import java.util.Scanner;
/**
*
* @author PC
*/
public class Main {
public static void main(String[] args) {
HashMap<String, customer> hashMap = new HashMap();
Scanner scan = new Scanner(System.in);
int chon, n;
do{
showMenu();
chon = Integer.parseInt(scan.nextLine());
switch(chon){
case 1:
System.out.println("Them khac hang moi");
customer cus = new customer();
cus.input();
hashMap.put(cus.getName(),cus);
break;
case 2:
System.out.println("Tim theo ten");
String name = scan.nextLine();
for (String str : hashMap.keySet()) {
if(hashMap.get(str).name.equalsIgnoreCase(name)){
hashMap.get(str).display();
}
}
break;
case 3:
System.out.println("Hien thi tat ca");
for (String str : hashMap.keySet()) {
customer cuss = hashMap.get(str);
cuss.display();
}
break;
case 4:
System.out.println("thoat");
break;
default:
System.out.println("moi nhap lai");
break;
}
}while(chon != 4);
}
public static void showMenu(){
System.out.println("1. Them khach hang moi");
System.out.println("2. Tim theo ten");
System.out.println("3. hien thi tat ca");
System.out.println("4. thoat");
System.out.println("Chon :");
}
}
/*
* 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 Test2;
import java.util.HashMap;
import java.util.Scanner;
/**
*
* @author PC
*/
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 scan = new Scanner(System.in);
System.out.println("Nhap ten :");
name = scan.nextLine();
System.out.println("Nhap email :");
email = scan.nextLine();
System.out.println("Nhap so dien thoai :");
phone = Integer.parseInt(scan.nextLine());
}
public void display(){
System.out.println(toString());
}
@Override
public String toString() {
return "customer{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
}
}
![Thành Lâm [T1907A]](https://www.gravatar.com/avatar/fb1b94f4caad069ee6e3f42ea2221b49.jpg?s=80&d=mm&r=g)
Thành Lâm
2020-04-10 09:06:48
package test;
import java.util.HashMap;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
HashMap<String, CUSTOMER> hashMap = new HashMap();
Scanner scan = new Scanner(System.in);
int choose, n;
do{
showMenu();
choose = Integer.parseInt(scan.nextLine());
switch(choose){
case 1:
System.out.println("Add new customer");
CUSTOMER cus = new CUSTOMER();
cus.input();
hashMap.put(cus.getName(),cus);
break;
case 2:
System.out.println("Find by name");
String name = scan.nextLine();
for (String str : hashMap.keySet()) {
if(hashMap.get(str).name.equalsIgnoreCase(name)){
hashMap.get(str).display();
}
}
break;
case 3:
System.out.println("Display all");
for (String str : hashMap.keySet()) {
CUSTOMER cuss = hashMap.get(str);
cuss.display();
}
break;
case 4:
System.out.println("Exit!!!");
break;
default:
System.out.println("Input fail!!!");
break;
}
}while(choose != 4);
}
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");
System.out.println("Choose :");
}
}
package test;
import java.util.Scanner;
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 scan = new Scanner(System.in);
System.out.println("Nhap ten :");
name = scan.nextLine();
System.out.println("Nhap email :");
email = scan.nextLine();
System.out.println("Nhap so dien thoai :");
phone = Integer.parseInt(scan.nextLine());
}
public void display(){
System.out.println(toString());
}
@Override
public String toString() {
return "customer{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
}
}
![lê văn phương [T1907A]](https://www.gravatar.com/avatar/a07ddfb51e1e7189c76b4e42dbdbcddc.jpg?s=80&d=mm&r=g)
lê văn phương
2020-04-10 09:04:54
/*
* 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 customerrelationshipmanagement;
import java.util.HashMap;
import java.util.Scanner;
/**
*
* @author HOME
*/
public class CustomerRelationshipManagement {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
HashMap<String, Customer> ma = new HashMap<>();
int choose;
do {
showMenu();
System.out.println("Enter choose: ");
choose = Integer.parseInt(scan.nextLine());
switch (choose) {
case 1:
Customer cus = new Customer();
cus.input();
ma.put(cus.getName(), cus);
break;
case 2:
System.out.println("Tìm tên: ");
String name = scan.nextLine();
for (String s : ma.keySet()) {
if (ma.get(s).name.equalsIgnoreCase(name)) {
ma.get(name).display();
} else {
System.out.println("Không thấy");
}
}
break;
case 3:
for (String s : ma.keySet()) {
Customer customer = ma.get(s);
customer.display();
}
break;
case 4:
System.out.println("Exit");
break;
default:
System.err.println("error");
break;
}
} while (choose != 4);
}
public static void showMenu() {
System.out.println("-------");
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");
System.out.println("Enter:");
}
}
![Luong Dinh Dai [T1907A]](https://www.gravatar.com/avatar/ca08fa4090e1038e541197564747f93c.jpg?s=80&d=mm&r=g)
Luong Dinh Dai
2020-04-10 09:00:47
/*
* 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 thithuchanh;
import java.util.HashMap;
import java.util.Scanner;
import static jdk.nashorn.internal.objects.NativeArray.map;
import static jdk.nashorn.internal.objects.NativeDebug.map;
/**
*
* @author FATE STORE
*/
public class Main {
public static void main(String[] args) {
HashMap<String, Customer> hashMap = new HashMap<String, Customer>();
Main main = new Main();
Scanner sc = new Scanner(System.in);
int sw;
do {
main.menu();
sw = sc.nextInt();
sc.nextLine();
switch (sw) {
case 1:
System.out.println("nhap thong tin customer : ");
Customer cus = new Customer();
cus.input();
hashMap.put(cus.getName(), cus);
break;
case 2:
System.out.println("Nhap ten customer can tim");
boolean check = false;
Customer custom = new Customer();
String find = sc.nextLine();
for (String key : hashMap.keySet()) {
Customer value = hashMap.get(key);
if (value.getName().equalsIgnoreCase(find)) {
check = true;
custom = value;
break;
}
}
if (check) {
custom.display();
} else {
System.out.println("khong tim thay customer: " + find);
}
break;
case 3:
for (String key : hashMap.keySet()) {
Customer value = hashMap.get(key);
value.display();
}
}
} while (sw != 4);
}
public void menu() {
System.out.print("**************************************\n1: Add new Customer\n2: Find by name\n3: Display all\n4: Exit\n");
}
}
/*
* 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 thithuchanh;
import java.util.Scanner;
/**
*
* @author FATE STORE
*/
public class Customer {
String name, age, email;
public Customer() {
}
public Customer(String name, String age, String email) {
this.name = name;
this.age = age;
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "Customer{" + "name=" + name + ", age=" + age + ", email=" + email + '}';
}
public void input() {
Scanner sc = new Scanner(System.in);
System.out.println("input name: ");
name = sc.nextLine();
System.out.println("input age: ");
age = sc.nextLine();
System.out.println("input email: ");
email = sc.nextLine();
}
public void display() {
System.out.println(toString());
}
}
![Nguyễn Văn Quang [T1907A]](https://www.gravatar.com/avatar/e40ab58e34debd5a0dbf4bcfa90bded0.jpg?s=80&d=mm&r=g)
Nguyễn Văn Quang
2020-04-10 08:59:28
public static void main(String[] args) {
HashMap<String, customer> hashMap = new HashMap();
Scanner scan = new Scanner(System.in);
int choose, n;
do{
showMenu();
choose = Integer.parseInt(scan.nextLine());
switch(choose){
case 1:
System.out.println("Add new customer");
customer cus = new customer();
cus.input();
hashMap.put(cus.getName(),cus);
break;
case 2:
System.out.println("Find by name");
String name = scan.nextLine();
for (String str : hashMap.keySet()) {
if(hashMap.get(str).name.equalsIgnoreCase(name)){
hashMap.get(str).display();
}
}
break;
case 3:
System.out.println("Display all");
for (String str : hashMap.keySet()) {
customer cuss = hashMap.get(str);
cuss.display();
}
break;
case 4:
System.out.println("Exit!!!");
break;
default:
System.out.println("Input fail!!!");
break;
}
}while(choose != 4);
}
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");
System.out.println("Choose :");
}
/*
* 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 test;
import java.util.Scanner;
/**
*
* @author Quang
*/
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 scan = new Scanner(System.in);
System.out.println("Nhap ten :");
name = scan.nextLine();
System.out.println("Nhap email :");
email = scan.nextLine();
System.out.println("Nhap so dien thoai :");
phone = Integer.parseInt(scan.nextLine());
}
public void display(){
System.out.println(toString());
}
@Override
public String toString() {
return "customer{" + "name=" + name + ", email=" + email + ", phone=" + phone + '}';
}
}
![Phạm Ngọc Minh [T1907A]](https://www.gravatar.com/avatar/9fa44938f36838ed4b4ac8e30e070c74.jpg?s=80&d=mm&r=g)
Phạm Ngọc Minh
2020-04-10 08:58:56
package Examk2;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
HashMap<Customer, String> Customer = new HashMap<>();
Scanner scan = new Scanner(System.in);
int choice;
do {
showMenu();
choice = Integer.parseInt(scan.nextLine());
switch (choice) {
case 1:
Customer customer = new Customer();
customer.input();
Customer.put(customer, customer.getName());
break;
case 2:
System.out.println("Enter name :");
String name ;
name = scan.nextLine();
Customer.keySet().forEach((W) -> {
if(W.getName().equalsIgnoreCase(name))
{
W.display();
}
else
{
System.out.println("N/A!");
}
});
break;
case 3:
Customer.keySet().forEach((W) -> {
W.display();
});
break;
case 4:
System.out.println("Exit.");
break;
default:
System.out.println("!!!YOU PICK THE WRONG HOUSE FOOL!!!");
break;
}
} while (choice != 4);
}
public static void showMenu() {
System.out.println("Menu :");
System.out.println("1. Add a customer.");
System.out.println("2. Find by name.");
System.out.println("3. Display all.");
System.out.println("4. Exit.");
}
}
package Examk2;
import java.util.Scanner;
public class Customer {
String name, email, phone_Number;
public Customer() {
}
public Customer(String name, String email, String phonenumer) {
this.name = name;
this.email = email;
this.phone_Number = phone_Number;
}
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 getPhonenumber() {
return phone_Number;
}
public void setPhonenumber(String phonenumer) {
this.phone_Number = phonenumer;
}
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_Number = scan.nextLine();
}
public void display() {
System.out.println(toString());
}
@Override
public String toString() {
return "Customer{" + "name = " + name + ", email = " + email + ", phonenumber = " + phone_Number + '}';
}
}