【发布时间】:2017-05-15 22:46:04
【问题描述】:
CurrencyConversion 为用户提供将美元转换为英镑或其他方式的选择。 (你可以假设 1 美元 = 1.64 英镑。)
// Import scanner
import java.util.Scanner;
public class MoneyConversion {
public static void main (String[] args) {
// Declare variable
final double RATE = 1.64;
// Declare currency
double dollar;
double Pounds;
// Call scanner from keyBoard
Scanner fromKeyboard = new Scanner(System.in);
// Ask user to enter the amount of pounds
System.out.print("Please write number of pounds");
// Read the value into variable
Pounds = fromKeyboard.nextDouble();
// Write the method for currency conversion
dollar = Pounds * RATE;
System.out.println("The number of dollars is " + dollar);
} // End of main
} // End currency conversion
【问题讨论】:
标签: java algorithm converter currency pseudocode