Pounds to Dollars
Здравейте,
някой може ли да ми каже защо това ми дава 80/100
2. Pounds to Dollars
Write a program that converts British pounds to US dollars formatted to 3th decimal point.
1 British Pound = 1.31 Dollars
Examples
Input Output
80 104.800
39 51.090
import java.math.BigDecimal;
import java.util.Scanner;
public class PoundsToDollars {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
BigDecimal britishPounds = new BigDecimal(scanner.nextLine());
BigDecimal dollar = new BigDecimal(1.31);
BigDecimal toDollars = britishPounds.multiply(dollar);
System.out.printf("%.3f", toDollars);
}
}
https://pastebin.com/cQP6ehC7
Благодаря
Здравейте,
Бихте ли могли да отговорите и на мен къде ми е грешката? Опитах няколко различни начина да реша задачата и винаги получавам 40/100 или 80/100.
Условие:
Pounds to Dollars
Write a program that converts British pounds to US dollars formatted to 3th decimal point.
1 British Pound = 1.31 Dollars
Examples
Input
Output
80
104.800
39
51.090
Моето решение:
https://pastebin.com/nMLXy2D0
Благодаря предварително за отделеното време!