-2
import java.util.*;

public class Ford {
    public static void main(String[] args) {
        System.out.println("Input for t for A(t)=1500(1/2)^t/14");
        Scanner sc = new Scanner(System.in);
        double t = sc.nextInt();
        double a = 1500;
        double b = 0.5;
        double c = 2;
        double d = 14;
        double e = t / 2;
        double f = 14 / 2;
        double g = e / f;
        double h = c * g;
        double i = a / d;
        double j = c / d;
        double k = a / (15 / 7);
        double m = java.lang.Math.pow(c, g);
        double n = java.lang.Math.ceil(a / m);
        System.out.println("The total answer is " + n + " rounded to the nearest" + " tenth gram after " + t + " hours");
        System.out.println("The exponent * 2 is " + m);
        System.out.println(g);
    }
}
SamHoque
  • 2,978
  • 2
  • 13
  • 43

1 Answers1

1
double t = sc.nextInt();

Your error is in this line, You are trying to save an int to a double use this instead

double t = sc.nextDouble();
SamHoque
  • 2,978
  • 2
  • 13
  • 43
  • and also `double k = a / (15 / 7);` does not seem right – Scary Wombat Dec 12 '18 at 02:37
  • @ScaryWombat Pretty sure the question wasn't about that since the title says `double it gives an error. An integer works fine` so this would be the obvious answer. But Yeah I am not a math guy you can address it in your own answer – SamHoque Dec 12 '18 at 02:38
  • `14 / 2` returns a warning aswell in my IDE, so that isn't right either for `double f = 14 / 2;` – SamHoque Dec 12 '18 at 02:38
  • No, the problem is that `(15 / 7)` does integer division and thus gives a result of `2`, not `2.14....` but as you say, that is not his question. – Scary Wombat Dec 12 '18 at 02:40
  • Well the OP can just do `15.0` no? – SamHoque Dec 12 '18 at 02:41
  • The problem was that the scanner was set to int, not double. – user9851152 Dec 12 '18 at 03:21
  • @user9851152 No, My answer already addresses the problem. You can't "SET" a scanner to an object, You can retrive an object from the scanner which may be an int or double. – SamHoque Dec 12 '18 at 03:30