私は、Javaでユーザーに従業員名と給料を尋ねるプログラムを書いています。給料が入力され、画面に表示されると、給与の前に数字の記号を付ける必要があります。どのように私はそれをやって行くだろうか?数字の前に数字記号を付けるには
ありがとうございます!
public static void main(String[] args) {
//use default constructor
//ask name
String name = JOptionPane.showInputDialog("What is Employee #1's name?");
//System.out.println(name);
//ask salary
double salary = Double.parseDouble(JOptionPane.showInputDialog("What is the employee's salary?"));
//System.out.print(salary);
//make an employee1 value
Employee employee1 = new Employee(name, salary);
//print out
System.out.println(employee1);
System.out.printf("Employee: %s%n", employee1.getName());
System.out.printf("Salary: %.3f%n", employee1.getSalary());
// System.out.printf("Employee: %s", employee1.getName());
JOptionPane.showMessageDialog(null, "This is the Employee's name:" + employee1.getName());
JOptionPane.showMessageDialog(null, "This is the Employee's salary:" + employee1.getSalary());
System.out.printf("%.3f", salary);
//employee 2
String name1 = JOptionPane.showInputDialog("What is Employee #2's name?");
double salary1 = Double.parseDouble(JOptionPane.showInputDialog("What is the employee's salary?"));
//System.out.print(salary);
//make an employee2 value
Employee employee2 = new Employee(name1, salary1);
//print out
System.out.println(employee2);
System.out.printf("Employee: %s%n", employee2.getName());
System.out.printf("Salary: %.3f%n", employee2.getSalary());
// System.out.printf("Employee: %s", employee2.getName());
JOptionPane.showMessageDialog(null, "This is the Employee's name:" + employee2.getName());
JOptionPane.showMessageDialog(null, "This is the Employee's salary:" + employee2.getSalary());
System.out.printf("%.3f", salary);
}
}
System.out.printf( "給与:#%.3f%n"、employee2.getSalary()); ? –
番号記号、それはどういう意味ですか?あなたは通貨simbolをお探しですか? –
「番号記号」とは何ですか?通貨記号?あなたのprtinf文字列の一部としてそれを持っていますか? –