Skip to content

Commit 569c2b1

Browse files
AC
1 parent b42756a commit 569c2b1

File tree

32 files changed

+519
-31
lines changed

32 files changed

+519
-31
lines changed

J04004/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.mycompany</groupId>
5+
<artifactId>J04004</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>16</maven.compiler.source>
11+
<maven.compiler.target>16</maven.compiler.target>
12+
</properties>
13+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.j04004;
7+
8+
/**
9+
*
10+
* @author Admin
11+
*/
12+
public class J04004 {
13+
// thuộc tính dạng private chỉ được dùng bên trong lớp này.
14+
private long tu, mau;
15+
//hàm tạo trong java cho đối tượng ps1, ps2 sử dụng.
16+
public J04004(long tu, long mau) {
17+
this.tu = tu;
18+
this.mau = mau;
19+
}
20+
// phương thức public cho đối tượng -->phải khởi tạo một đối tượng mới có thể truy cập được.
21+
// phương thức static --> được phép truy cập mà không cần tạo một đối tượng
22+
public long getTu() {
23+
return tu;
24+
}
25+
26+
public void setTu(long tu) {
27+
this.tu = tu;
28+
}
29+
30+
public long getMau() {
31+
return mau;
32+
}
33+
34+
public void setMau(long mau) {
35+
this.mau = mau;
36+
}
37+
38+
public long timUSCLN(long a, long b) {
39+
while (a != b) {
40+
if (a > b) {
41+
a -= b;
42+
} else {
43+
b -= a;
44+
}
45+
}
46+
return a;
47+
}
48+
49+
public void toiGianPhanSo() {
50+
long i = timUSCLN(this.getTu(), this.getMau());
51+
this.setTu(this.getTu() / i);
52+
this.setMau(this.getMau() / i);
53+
}
54+
// tạo một đối tượng ps từ lớp J04004
55+
public void congPhanSo(J04004 ps) {
56+
long ts = this.getTu() * ps.getMau() + ps.getTu() * this.getMau();
57+
long ms = this.getMau() * ps.getMau();
58+
J04004 phanSoTong = new J04004(ts, ms);
59+
phanSoTong.toiGianPhanSo();
60+
System.out.println(phanSoTong.tu + "/" + phanSoTong.mau);
61+
}
62+
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.j04004;
7+
8+
/**
9+
*
10+
* @author Admin
11+
*/
12+
import java.util.*;
13+
public class Nhap {
14+
public static void main(String[] args) {
15+
Scanner in = new Scanner(System.in);
16+
// khỏi tạo một đối tượng tên ps1, ps2 từ một lớp J04004
17+
J04004 ps1=new J04004(in.nextLong(),in.nextLong());
18+
J04004 ps2=new J04004(in.nextLong(),in.nextLong());
19+
ps1.congPhanSo(ps2);
20+
}
21+
}
Binary file not shown.

J04006/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.mycompany</groupId>
5+
<artifactId>J04006</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>16</maven.compiler.source>
11+
<maven.compiler.target>16</maven.compiler.target>
12+
</properties>
13+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.mycompany.j04006;
2+
3+
/*
4+
* To change this license header, choose License Headers in Project Properties.
5+
* To change this template file, choose Tools | Templates
6+
* and open the template in the editor.
7+
*/
8+
9+
/**
10+
*
11+
* @author Admin
12+
*/
13+
import java.text.SimpleDateFormat;
14+
import java.util.Date;
15+
public class J04006 {
16+
String name,cls,date;
17+
Float degree;
18+
public J04006(String name, String cls,String date, Float degree){
19+
this.name = name;
20+
this.cls = cls;
21+
this.date = date;
22+
this.degree = degree;
23+
}
24+
public void result(){
25+
try {
26+
SimpleDateFormat dt = new SimpleDateFormat("dd/mm/yyyy");
27+
Date d = dt.parse(date);
28+
date = dt.format(d);
29+
} catch(Exception e) {
30+
e.printStackTrace();
31+
}
32+
String degre = String.format("%.2f", this.degree);
33+
// Date date = formatter.format(this.date);
34+
System.out.print("B20DCCN001 " + this.name + " " +this.cls + " " + date+" " + degre);
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.mycompany.j04006;
2+
3+
/*
4+
* To change this license header, choose License Headers in Project Properties.
5+
* To change this template file, choose Tools | Templates
6+
* and open the template in the editor.
7+
*/
8+
9+
/**
10+
*
11+
* @author Admin
12+
// */
13+
//import com.mycompany.j04006.J04006;
14+
import java.util.*;
15+
public class Nhap {
16+
public static void main(String[] args){
17+
Scanner in = new Scanner(System.in);
18+
J04006 tmp = new J04006(in.nextLine(),in.nextLine(),in.nextLine(),in.nextFloat());
19+
tmp.result();
20+
}
21+
}
Binary file not shown.

J04007/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.mycompany</groupId>
5+
<artifactId>J04007</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>16</maven.compiler.source>
11+
<maven.compiler.target>16</maven.compiler.target>
12+
</properties>
13+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.mycompany.j04007;
2+
3+
/*
4+
* To change this license header, choose License Headers in Project Properties.
5+
* To change this template file, choose Tools | Templates
6+
* and open the template in the editor.
7+
*/
8+
9+
/**
10+
*
11+
* @author Admin
12+
*/
13+
import java.text.SimpleDateFormat;
14+
import java.util.Date;
15+
public class J04007 {
16+
String name, gender, date, address,code,contract;
17+
public J04007(String name, String gender, String date, String address, String code, String contract){
18+
this.name = name;
19+
this.gender = gender;
20+
this.date = date;
21+
this.address = address;
22+
this.code = code;
23+
this.contract = contract;
24+
}
25+
public void result(){
26+
try {
27+
SimpleDateFormat dt = new SimpleDateFormat("dd/mm/yyyy");
28+
Date d = dt.parse(date);
29+
date = dt.format(d);
30+
} catch(Exception e) {
31+
e.printStackTrace();
32+
}
33+
try{
34+
SimpleDateFormat dt_1 = new SimpleDateFormat("dd/mm/yyyy");
35+
Date c = dt_1.parse(contract);
36+
contract = dt_1.format(c);
37+
} catch (Exception e) {
38+
e.printStackTrace();
39+
}
40+
System.out.println("00001 " + this.name + " " + this.gender + " " + this.date + " " + this.address + " " + this.code + " " + this.contract );
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.j04007;
7+
8+
/**
9+
*
10+
* @author Admin
11+
*/
12+
import java.util.*;
13+
public class Nhap {
14+
public static void main(String[] args){
15+
Scanner sc = new Scanner(System.in);
16+
J04007 tmp = new J04007(sc.nextLine(), sc.nextLine(), sc.nextLine(),sc.nextLine(),sc.nextLine(),sc.nextLine() );
17+
tmp.result();
18+
}
19+
}
Binary file not shown.

PS/Nhap.java

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package PS;
2+
import java.util.*;
3+
// import PS.PhanSo;
4+
5+
public class Nhap {
6+
public static void main(String[] args) {
7+
Scanner sc = new Scanner(System.in);
8+
PhanSo ps1 = new PhanSo(sc.nextLong(),sc.nextLong());
9+
ps1.rutGon();
10+
}
11+
}

PS/PhanSo.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package PS;
2+
3+
public class PhanSo {
4+
public long tu,mau;
5+
public PhanSo(long tu, long mau) {
6+
this.tu = tu;
7+
this.mau = mau;
8+
}
9+
public String toString(long tu , long mau){
10+
return tu + "/" + mau;
11+
}
12+
public void rutGon(){
13+
long GCD = gcd(this.tu,this.mau);
14+
System.out.println(toString(this.tu/GCD, this.mau/GCD));
15+
}
16+
public long gcd(long a,long b){
17+
if(b==0) return a;
18+
return gcd(b,a%b);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.ps1;
7+
8+
/**
9+
*
10+
* @author Admin
11+
*/
12+
import java.util.*;
13+
public class Nhap {
14+
15+
public static void main(String[] args) {
16+
Scanner sc = new Scanner(System.in);
17+
PhanSo ps1 = new PhanSo(sc.nextLong(),sc.nextLong());
18+
ps1.rutGon();
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.ps1;
7+
8+
/**
9+
*
10+
* @author Admin
11+
*/
12+
public class PhanSo {
13+
long tu,mau;
14+
public PhanSo(long tu, long mau) {
15+
this.tu = tu;
16+
this.mau = mau;
17+
}
18+
public String toString(long tu , long mau){
19+
return tu + "/" + mau;
20+
}
21+
public void rutGon(){
22+
long GCD = gcd(this.tu,this.mau);
23+
System.out.println(toString(this.tu/GCD, this.mau/GCD));
24+
}
25+
public long gcd(long a,long b){
26+
if(b==0) return a;
27+
return gcd(b,a%b);
28+
}
29+
}
802 Bytes
Binary file not shown.

Test/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.mycompany</groupId>
5+
<artifactId>Test</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>16</maven.compiler.source>
11+
<maven.compiler.target>16</maven.compiler.target>
12+
</properties>
13+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.mycompany.test;
2+
3+
/*
4+
* To change this license header, choose License Headers in Project Properties.
5+
* To change this template file, choose Tools | Templates
6+
* and open the template in the editor.
7+
*/
8+
9+
/**
10+
*
11+
* @author Admin
12+
*/
13+
public class J04007 {
14+
String name, gender, date, address,code,contract;
15+
public J04007(String name, String gender, String date, String address, String code, String contract){
16+
this.name = name;
17+
this.gender = gender;
18+
this.date = date;
19+
this.address = address;
20+
this.code = code;
21+
this.contract = contract;
22+
}
23+
public void result(){
24+
// try {
25+
// SimpleDateFormat dt = new SimpleDateFormat("dd/mm/yyyy");
26+
// Date d = dt.parse(date);
27+
// date = dt.format(d);
28+
// } catch(Exception e) {
29+
// e.printStackTrace();
30+
// }
31+
// try{
32+
// SimpleDateFormat dt_1 = new SimpleDateFormat("dd/mm/yyyy");
33+
// Date c = dt_1.parse(contract);
34+
// contract = dt_1.format(c);
35+
// } catch (Exception e) {
36+
// e.printStackTrace();
37+
// }
38+
System.out.println("00001 " + this.name + " " + this.gender + " " + this.date + " " + this.address + " " + this.code + " " + this.contract );
39+
}
40+
}

0 commit comments

Comments
 (0)