java - Unexpected Type -
i'm new java. having problem block of code. attempting find minimum number of coins needed pay amount (in example 398 cents).
i'm getting error unexpected type. required: variable. found: value.
after attempt subtract on lines 20, 25, 30, 35, 40, 45 , 50. want subtract value. think have use method i'm unsure how. appreciated.
public class makingchange { public static void main(string[] args) { int = 398; int b; int c; int d; int e; int f; int g; int h; int j; int k; int i; int l; int m; int n; int o; if (a > 0) { if (a >= 200) { = (int) / 200; - * 200 = b; } else { = b; } if (b >= 100) { j = (int) / 100; b - j * 100 = c; } else { b = c; } if (c >= 25) { k = (int) c / 25; c - k * 25 = d; } else { c = d; } if (d >= 100) { l = (int) d / 100; b - l * 100 = c; } else { d = e; } if (e >= 10) { m = (int) e / 10; e - m * 10 = f; } else { e = f; } if (f >= 5) { n = (int) f / 5; f - n * 5 = g; } else { f = g; } if (g >= 1) { o = (int) g / 1; g - o = h; } else { g = h; } system.out.println(i + j + k + l + m + n + o); } } }
an assignment operation in java language involves following syntax:
variable = expression
it first evaluates expression on right side , assigns resulting value operand on left. going rule, lhs of assignment must strictly variable can reference primitive type, user defined type or array.
the blocks in code violate principle are:
- * 200 = b; b - j * 100 = c; c - k * 25 = d; b - l * 100 = c; e - m * 10 = f; f - n * 5 = g; g - o = h;
Comments
Post a Comment