1. Trang chủ
  2. » Công Nghệ Thông Tin

on tap javax

32 337 5
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề On Tap Javax
Trường học Unknown University
Chuyên ngành Computer Science
Thể loại Bài tập
Năm xuất bản 2023
Thành phố Unknown City
Định dạng
Số trang 32
Dung lượng 23,36 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

java

Trang 2

Bài 3:

Class SV{

String hoTen=”Nguyen Thanh Truc”;

Int tuoi=”2”;//sai: giá trị không đặt trong dấu nháy kép

Public abstrac void tong(){

Int x=20,s=0;//sai: tham biến x không thay đổi được

For(i=1;i<x;i++) s+=1;}

Public static void main(String arg){//sai: thiếu dấu [] vì là mảng số

Trang 3

* To change this template, choose Tools | Templates

* and open the template in the editor

Trang 4

public static String nhapchuoi(){

DataInputStream dis=new DataInputStream(System.in); String str;

Trang 5

public void in(){

System.out.println("Ho Ten: "+hoTen);

System.out.println("Ma sinh vien: "+masv);

System.out.println("Ngay Sinh: "+ngaySinh);

System.out.println("Dia Chi: "+diaChi);

System.out.println("Diem 1:"+diem1+" Diem 2:"+diem2+" Diem 3:"+diem3); System.out.println("Diem TB: "+DTB);

}

}

/**

*

Trang 7

for(j=1;j<=i;j++){

if("Thai Nguyen".equals(sinhvien[j].diaChi)) { sinhvien[j].in();

}

}

}

}

Trang 8

/*

* To change this template, choose Tools | Templates

* and open the template in the editor

Trang 9

x=Integer.parseInt(is.readLine());}catch(IOException e){x=0;}

int A[]=new int[60];

for(y=0;y<x;y++){

System.out.print("nhapphantu A["+y+"]: "); A[y]=Integer.parseInt(is.readLine()); }

Trang 12

System.out.print("\ntongcac so o vi tri chan: "+i);

}

}

Bài 3:

/*

* To change this template, choose Tools | Templates

* and open the template in the editor

Trang 13

System.out.print("nhapkichthuoc ma tranvuong: "); m=Integer.parseInt(is.readLine());

Trang 14

int B[][]=new int[40][40];

Trang 15

int C[]=new int [40];

z=0;

for(i=1;i<=m;i++){

k=A[i][i];

Trang 16

int D[]=new int[40];

Trang 17

* To change this template, choose Tools | Templates

* and open the template in the editor

Trang 18

* @author le

*/

public class Bai1server {

public final static int port=55;

int tong=0;

for(inti=0;i<9;i++){

tong+=a[i];

Trang 19

* To change this template, choose Tools | Templates

* and open the template in the editor

public class bai1client {

public static final int port=55;

Trang 20

// TODO code application logic here

DataInputStream dis=new DataInputStream(System.in);try{

Socket s=new Socket("LocalHost",port);

}

Bài 2:

Server;

/*

* To change this template, choose Tools | Templates

* and open the template in the editor

Trang 21

public class bai2server {

public final static int port=50;

/**

* @paramargs the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

System.out.print("\nchuoinhanduoc: "+st);

Trang 22

System.out.print("\nchuoiduocchuyendoi: "+str);os.writeUTF(str);

}catch(IOExceptionie){System.out.print(ie);} }

* To change this template, choose Tools | Templates

* and open the template in the editor

public class bai2client {

public final static int port=50;

/**

* @paramargs the command line arguments */

Trang 23

public static void main(String[] args) {

// TODO code application logic here

DataInputStream dis=new DataInputStream(System.in);

try{

while(true){

Socket s=new Socket("LocalHost",port);

DataInputStream is=new DataInputStream(s.getInputStream());DataOutputStreamos=new DataOutputStream(s.getOutputStream()); String st,str;

* To change this template, choose Tools | Templates

* and open the template in the editor

*/

Trang 24

public class bai3server {

public final static int port=50;

/**

* @paramargs the command line arguments */

public static void main(String[] args) {

// TODO code application logic here String st,str;

try{

ServerSocketss=new ServerSocket(port);while(true){

try{

Socket s=ss.accept();

Trang 25

DataInputStream is=new DataInputStream(s.getInputStream());DataOutputStreamos=new DataOutputStream(s.getOutputStream());st=is.readUTF();

* To change this template, choose Tools | Templates

* and open the template in the editor

Trang 26

*

* @author le

*/

public class bai3client {

public final static int port=50;

/**

* @paramargs the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

DataInputStream dis=new DataInputStream(System.in);

try{

while(true){

Socket s=new Socket("LocalHost",port);

DataInputStream is=new DataInputStream(s.getInputStream());DataOutputStreamos=new DataOutputStream(s.getOutputStream()); String st,str;

Trang 27

Bìa 19:

Server:

/*

* To change this template, choose Tools | Templates

* and open the template in the editor

public class Bai19 {

public final static int port=55;

Trang 28

DataInputStream is=new DataInputStream(s.getInputStream());DataOutputStreamos=new DataOutputStream(s.getOutputStream()); String st;

Trang 29

* To change this template, choose Tools | Templates

* and open the template in the editor

*/

packagethuchanh;

Trang 30

public class bai19client {

public final static int port=55;

/**

* @paramargs the command line arguments

*/

public static void main(String[] args) throws IOException {

// TODO code application logic here

DataInputStream dis=new DataInputStream(System.in);

try{

while(true){

Socket s=new Socket("127.0.0.1",port);

DataInputStream is=new DataInputStream(s.getInputStream());DataOutputStreamos=new DataOutputStream(s.getOutputStream());System.out.print("nhap so: ");

Trang 31

* To change this template, choose Tools | Templates

* and open the template in the editor

Trang 32

Runtime rt=Runtime.getRuntime();

Process p=rt.exec("logoff");// câulệnh”tắtmáykhỏeđộngmáy, khởiđộngchương trình.exe” }

}

Ngày đăng: 04/03/2013, 16:07

Xem thêm

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w