SKIITE
Lv 7
SKIITE asked in 電腦與網際網路程式設計 · 10 years ago

Java程式問題

public class ChangeCount {

public static void main(String[] args) {

int quarters;

int dimes;

int nickels;

int pennies;

double dollars;

TextIO.put("Enter the number of quarters: ");

quarters = TextIO.getInt();

TextIO.put("Enter the number of dimes: ");

dimes = TextIO.getInt();

TextIO.put("Enter the number of nickels: ");

nickels = TextIO.getInt();

TextIO.put("Enter the number of pennies: ");

pennies = TextIO.getInt();

dollars = (0.25 * quarters) + (0.10 * dimes)

+ (0.05 * nickels) + (0.01 * pennies);

TextIO.putln();

TextIO.put("The total in dollars is $");

TextIO.putf("%1.2f", dollars); // Formatted output!

TextIO.putln();

}

}

跑程式的時候

出現

Enter the number of quarters: 10

Enter the number of dimes: ? 11

Enter the number of nickels: ? 12

Enter the number of pennies: ? 13

The total in dollars is $4.33

二三四行的問號

請問是怎麼回事?

感激不盡!!!

Update:

我問的是程式運行後為什麼出現問號

不是問英文單字的問題

1 Answer

Rating
  • 10 years ago
    Favorite Answer

    夭壽!!!

    This is English question but not java question.

    You're too lazy to open a dictionary to find out

    2.Dime: 一角錢

    3.Nickels: 五分錢

    4.Penny: 一分錢

    2011-06-29 10:07:12 補充:

    haaa

    That'ts TextIO.GetInt's side effect.

    The first time GetInt will not prompt "?"

    And then it will prompt "?"

    If can skip this, use GetDouble

    or modify TextIO class

    2011-06-29 10:19:26 補充:

    Or.............

    you can use getlnInt to avoid this boring problem

Still have questions? Get your answers by asking now.