0% found this document useful (0 votes)
7 views2 pages

Lambaijv

The document contains four Java classes: HelloWorld, AverageThree, TripleEquals, and ConvertUnit1. HelloWorld prints 'Hello world' ten times, AverageThree calculates the average of three numbers passed as arguments, TripleEquals checks if three input strings are equal, and ConvertUnit1 converts a length in meters to inches. Each class includes error handling for incorrect input arguments.

Uploaded by

ha496891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Lambaijv

The document contains four Java classes: HelloWorld, AverageThree, TripleEquals, and ConvertUnit1. HelloWorld prints 'Hello world' ten times, AverageThree calculates the average of three numbers passed as arguments, TripleEquals checks if three input strings are equal, and ConvertUnit1 converts a length in meters to inches. Each class includes error handling for incorrect input arguments.

Uploaded by

ha496891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

public class HelloWorld {

public static void main(String[] args) {

for(int i = 0;i<10;i++) {

System.out.println("Hello world");

Bai 2

public class AverageThree {

public static void main(String[] args) {

if (args.length != 3) {

return;

try {

double num1 = Double.parseDouble(args[0]);

double num2 = Double.parseDouble(args[1]);

double num3 = Double.parseDouble(args[2]);

double average = (num1 + num2 + num3) / 3;

System.out.println(average);

} catch (NumberFormatException e) {

Bai3

public class TripleEquals {

public static void main(String[] args) {

if (args.length != 3) {

System.out.println("Vui lòng nhập đúng 3 tham số.");

return;
}

boolean areEqual = args[0].equals(args[1]) && args[1].equals(args[2]);

System.out.println(areEqual);

Bai4

public class ConvertUnit1 {

public static void main(String[] args) {

if (args.length != 1) {

System.out.println("Hay nhap mot so thuc cho chieu dai tinh bang met.");

return;

try {

double meters = Double.parseDouble(args[0]);

double inches = meters * 39.3700787;

inches = Math.round(inches * 100.0) / 100.0;

System.out.println(inches);

} catch (NumberFormatException e) {

System.out.println("Gia tri nhap vao khong hop le. Hay nhap mot so thuc.");

You might also like