Account

Report a typo

There is a class named Account. It includes three fields: id, code and balance.

Override the method toString() in this class. The method should return a string representation of an instance of the Account.

Do not make the Account class public.

Example

Account{id=10, code='123-456-789', balance=2000}
Write a program in Java 17
import java.util.Scanner;

class Account {

private long id;
private String code;
private Long balance;

public Account(long id, String code, Long balance) {
this.id = id;
this.code = code;
this.balance = balance;
}

// Override toString() here
}

/* Do not change code below */
public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

String[] parts = scanner.nextLine().split("\\s+");

long id = Long.parseLong(parts[0]);
String code = parts[1];
long balance = Long.parseLong(parts[2]);

Object acc = new Account(id, code, balance);

System.out.println(acc.toString());
}
}
___

Create a free account to access the full topic