Java Basic- Nhập xuất java - Scanner trong java
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Nguyen Tri Duc [java1_online]](https://www.gravatar.com/avatar/9ad80c7352fd64a202fbfb45d9ca9fb1.jpg?s=80&d=mm&r=g)
Nguyen Tri Duc
2023-04-15 14:42:14
import java.util.Scanner;
public class BaiTap_Scanner {
public static void main(String[] args) {
String name;
String address;
String email;
int age;
int phone;
Scanner sc = new Scanner(System.in);
System.out.println("Nhap ten:");
name = sc.nextLine();
System.out.println("Nhap tuoi: ");
age = sc.nextInt();
sc.nextLine();
System.out.println("Nhap dia chi: ");
address = sc.nextLine();
System.out.println("Nhap email: ");
email = sc.nextLine();
System.out.println("Nhap so dien thoai: ");
phone = sc.nextInt();
System.out.println("Ten: " + name);
System.out.println("Tuoi: " + age);
System.out.println("Dia chi: " + address);
System.out.println("email: " + email);
System.out.println("Phone: " + phone);
}
}
![Trần Nhựt Linh [java1_online]](https://www.gravatar.com/avatar/6e945f8e29edcd38ec9b7492c0265f02.jpg?s=80&d=mm&r=g)
Trần Nhựt Linh
2023-03-26 05:27:19
public class JavaBasic {
public static void main(String[] args) {
String ten;
int tuoi;
String diachi;
String email;
String sdt;
Scanner scan = new Scanner(System.in);
System.out.println("Nhap ten:");
ten = scan.nextLine();
System.out.println("Nhap tuoi:");
tuoi = scan.nextInt();
System.out.println("Nhap Email:");
scan.nextLine();
email = scan.nextLine();
System.out.println("Nhap dia chi:");
diachi = scan.nextLine();
System.out.println("Nhap sdt:");
sdt = scan.nextLine();
System.out.println("ten:" + ten +"; tuoi:" + tuoi +"; dia chi:" + diachi+"; email:" + email +"; sđt:" + sdt);
}
}
![le anh tuan [java1_online]](https://www.gravatar.com/avatar/0c79bbaaa43a903799a613fb8a163e0a.jpg?s=80&d=mm&r=g)
le anh tuan
2022-08-31 11:58:33
import java.util.Scanner;
public class JavaBasic {
public static void main(String[] args) {
String name;
int age;
String address;
String email;
String foneNumber;
Scanner scanner = new Scanner(System.in);
System.out.print("Nhap ten: ");
name = scanner.nextLine();
System.out.print("Nhap tuoi: ");
age = scanner.nextInt();
System.out.print("Nhap dia chi: ");
address = scanner.nextLine();
System.out.print("Nhap email: ");
email = scanner.nextLine();
System.out.print("Nhap SDT: ");
foneNumber = scanner.nextLine();
System.out.println("Ten: "+name);
System.out.println("Tuoi: "+age);
System.out.println("Dia chi: "+address);
System.out.println("Email: "+email);
System.out.println("SDT: "+foneNumber);
}
}
Khi em chạy code, đến dòng nhập địa chỉ thì chương trình bỏ qua không nhập được. Thầy xem lại giúp em em bị sai ở điểm nào ạ!![Nguyễn Viết Nguyên [java1_online]](https://www.gravatar.com/avatar/ca0f47db043b00fca52a41f529dd9c8a.jpg?s=80&d=mm&r=g)
Nguyễn Viết Nguyên
2022-07-13 10:33:59
import java.util.Scanner;
public class LearnScanner {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
String name, address, email, phone;
int age;
System.out.println("Enter your name: ");
name = scanner.nextLine();
System.out.println("Enter your age: ");
age = scanner.nextInt();
scanner.nextLine();
System.out.println("Enter your address: ");
address = scanner.nextLine();
System.out.println("Enter your email: ");
email = scanner.nextLine();
System.out.println("Enter your phone number: ");
phone = scanner.nextLine();
System.out.printf("%s-%d-%s-%s-%s",name, age, address, email, phone);
}
}
![Hoàng Anh [C2010G]](https://www.gravatar.com/avatar/e73c31efff649e599b1e4320b6bfb1a9.jpg?s=80&d=mm&r=g)
Hoàng Anh
2022-06-17 13:45: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 c2108l;
import java.util.Scanner;
/**
*
* @author Hoàng Anh
*/
public class bai2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Nhập tên: ");
String name = input.nextLine();
System.out.println("Nhập tuổi: ");
int age = Integer.parseInt(input.nextLine()); //sử dụng nextLine thay vì nextInt đẻ k bị trôi lệnh
System.out.println("Nhập địa chỉ: ");
String address = input.nextLine();
System.out.println("Nhập email: ");
String email = input.nextLine();
System.out.println("Nhập số điện thoại: ");
float phonenumber = input.nextFloat();
System.out.format("\n tên: %s\n tuổi: %d\n địa chỉ: %s\n email: %s\n số điện thoại: %f", name,age,address,email,phonenumber);
}
}
![Phạm Đăng Khoa [community,C2010L]](https://www.gravatar.com/avatar/c38babdc190b58e31608b8ddefc3ba1a.jpg?s=80&d=mm&r=g)
Phạm Đăng Khoa
2021-07-01 13:30:40
/*
* 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 main;
import java.util.Scanner;
/**
*
* @author Khoa Pham
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name;
String diachi,email;
int sdt,tuoi;
System.out.println("Nhập tên: ");
name = input.nextLine();
System.out.println("Nhập địa chỉ: ");
diachi = input.nextLine();
System.out.println("Nhập email: ");
email = input.nextLine();
System.out.println("Nhập SDT: ");
sdt = input.nextInt();
System.out.println("Nhap Tuoi: ");
tuoi = input.nextInt();
System.out.format("Ten : %s \n Dia chi: %s \n Email: %s \n SDT: %d \n Tuoi: %s ",name,diachi,email,sdt,tuoi);
}
}
/*
* 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 main;
import java.util.Scanner;
/**
*
* @author Khoa Pham
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name;
String diachi,email;
int sdt,tuoi;
System.out.println("Nhập tên: ");
name = input.nextLine();
System.out.println("Nhập địa chỉ: ");
diachi = input.nextLine();
System.out.println("Nhập email: ");
email = input.nextLine();
System.out.println("Nhập SDT: ");
sdt = input.nextInt();
System.out.println("Nhap Tuoi: ");
tuoi = input.nextInt();
System.out.format("Ten : %s \n Dia chi: %s \n Email: %s \n SDT: %d \n Tuoi: %s ",name,diachi,email,sdt,tuoi);
}
}
![Trần Việt Đức Anh [C2010L]](https://www.gravatar.com/avatar/caee507e11365ca2cf5068cbea5c740a.jpg?s=80&d=mm&r=g)
Trần Việt Đức Anh
2021-06-29 18:13:21
/*
Nhập thông tin sinh viên gồm các thuộc tính : Tên, tuổi, địa chỉ, email, số điện thoại.
Và hiển thị thông tin ra màn hình sau khi nhập.
*/
package Lession1;
import java.util.Scanner;
/**
*
* @author Tran Viet Duc Anh
*/
public class Ur_Info {
public static void main(String[] args) {
Scanner Info = new Scanner(System.in);
System.out.println("Please enter your name: ");
String name = Info.nextLine();
System.out.println("Please enter your address: ");
String addr = Info.nextLine();
System.out.println("Please enter your Email: ");
String email = Info.nextLine();
System.out.println("Please enter your phone number: ");
int pnum = Info.nextInt();
System.out.println("Please enter your age: ");
int age = Info.nextInt();
System.out.format("Name: %s\n Address: %s\n Email: %s\n Phone Number: 0%d\n Age: %d",name,addr,email,pnum,age);
}
}
![Hoàng Anh [community,C2010G]](https://www.gravatar.com/avatar/e73c31efff649e599b1e4320b6bfb1a9.jpg?s=80&d=mm&r=g)
Hoàng Anh
2021-06-29 15:21:20
/*
* 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 javaapplication4;
import java.util.Scanner;
/**
*
* @author Bom1
*/
public class baitap2 {
public static void main(String[] args) {
Scanner add = new Scanner(System.in);
Scanner input = new Scanner(System.in);
System.out.println("Nhập tên sinh viên:");
String name = add.nextLine();
System.out.println("Nhập tuổi sinh viên:");
int age = input.nextInt();
System.out.println("Nhập địa chỉ sinh viên:");
String adress = add.nextLine();
System.out.print("Nhập email sinh viên: \n");
String email = add.nextLine();
System.out.println("Nhập số điện thoại sinh viên:");
int phonenumber = input.nextInt();
System.out.format("Tên: %s ,Tuổi: %d ,Địa chỉ: %s ,email: %s ,Số điện thoại: %d", name,age,adress,email,phonenumber);
}
}
![Võ Như Việt [C2010L]](https://www.gravatar.com/avatar/fb93c99beb23339eb21f4d4ffe8981af.jpg?s=80&d=mm&r=g)
Võ Như Việt
2021-06-29 13:59:32
/*
* 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 vietvo.full.basic;
import java.util.Scanner;
/**
*
* @author ADMIN
*/
public class NhapXuatJava {
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.println("Vui long nhap Ten: ");
String ten = input.nextLine();
System.out.println("Vui long nhap Diachi: ");
String diachi = input.nextLine();
System.out.println("Vui long nhap Email: ");
String email = input.nextLine();
System.out.println("Vui long nhap SDT: ");
int sdt = input.nextInt();
System.out.println("Vui long nhap Tuoi");
int tuoi = input.nextInt();
System.out.format("Ten : %s \n DiaChi: %s \n Email: %s \n SDT: 0%d \n Tuoi: %d", ten,diachi,email,sdt,tuoi);
}
}
![hieuvm0512 [community,C2010L]](https://www.gravatar.com/avatar/0cacbf21fed14b987a433597d2edc14f.jpg?s=80&d=mm&r=g)
hieuvm0512
2021-06-29 13:27: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 com.mycompany.jv1;
import java.util.Scanner;
/**
*
* @author vuive
*/
public class stu {
public static void main(String[] agrs){
System.out.println("Nhap Ten: ");
Scanner input = new Scanner(System.in);
String ten = input.nextLine();
System.out.println("Nhap tuoi: ");
int tuoi = input.nextInt();
input.nextLine();
System.out.println("Nhap email: ");
String email = input.nextLine();
System.out.println("Nhap sdt: ");
int sdt = input.nextInt();
System.out.format("Sinh vien :%s \n tuoi:%d \n email:%s \n SDT: 0%d", ten,tuoi,email,sdt );
}
}