为了账号安全,请及时绑定邮箱和手机立即绑定

如何解决?我对Java非常陌生

如何解决?我对Java非常陌生

慕盖茨4494581 2021-11-11 14:21:44
打包应用程序;导入 java.util.Scanner; 导入 java.util.UUID;公共类 AccountThis { 私有静态扫描仪扫描仪;public static void main( String[] args ) {    //name input    scanner = new Scanner( System.in );       System.out.print( "Type your name: " );        String nameInput = scanner.nextLine();            System.out.println("Hello" + " " + nameInput);        //deposit input             scanner = new Scanner( System.in );               System.out.print( "Type how much you want to deposit:" );                double depositInput = scanner.nextDouble();                    System.out.println("you want to deposit" + " " + depositInput + "$");                    public AccountThis(String id) {                        System.out.println("ID Generated"                                + "Please Write it down :" + id);                }                    class RandomStringUUID {}                    public id = randID;{                        UUID randID = UUID.randomUUID();                        UUID randomUUIDString = randID;                        System.out.println(randomUUIDString );                    new AccountThis( nameInput, depositInput, id);                    }                    {                    }            }public AccountThis() {    System.out.println( "created an account." );}public AccountThis( String nameInput ) {    System.out.println( " created account with name " + nameInput );}public AccountThis(double depositInput) {    System.out.println(depositInput + "$" + "added to your account!" );}}我是 Java 新手,我正在尝试获取 id 并将其分配给带有一些文本的控制台,如您所见,如果您能帮我弄清楚,我会失败一点,我会非常高兴顺便说一句,我称它为 id,因为我整晚都在使用它,但无法弄清楚。
查看完整描述

1 回答

?
偶然的你

TA贡献1841条经验 获得超3个赞

试试这个代码。它工作正常


import java.util.Scanner;

import java.util.UUID;


public class AccountThis {


  private static Scanner scanner;



  public AccountThis(String nameInput) {


    System.out.println(" created account with name " + nameInput);

  }


  public AccountThis() {

    System.out.println("created an account.");

  }


  public AccountThis(double depositInput) {


    System.out.println(depositInput + "$" + "added to your account!");

  }


  public AccountThis(String nameInput, double depositInput, String id) {

    System.out.println(" created account with \n ID : " + id + ", \n name : " + nameInput);

    System.out.println(depositInput + "$" + "added to your account!");

  }


  public static void main(String[] args) {

    //name input

    scanner = new Scanner(System.in);

    System.out.print("Type your name: ");

    String nameInput = scanner.nextLine();

    System.out.println("Hello" + " " + nameInput);


    //deposit input

    scanner = new Scanner(System.in);

    System.out.print("Type how much you want to deposit:");

    double depositInput = scanner.nextDouble();

    System.out.println("you want to deposit" + " " + depositInput + "$");


    UUID randID = UUID.randomUUID();

    String id=randID.toString();


    new AccountThis(nameInput, depositInput,id);

  }

}


查看完整回答
反对 回复 2021-11-11
  • 1 回答
  • 0 关注
  • 124 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信