+ 1

Unhandled exception: type 'String' is not a subtype of type 'int' of 'times'

import 'dart:io'; void main(List<String> args) { var w1, item1, w2, item2; print('Weight-Item1: '); w1 = stdin.readLineSync(); print('Number of Items: '); item1 = stdin.readLineSync(); print('Weight-Item2: '); w2 = stdin.readLineSync(); print('Number of Items: '); item2 = stdin.readLineSync(); var result = ((w1 * item1) + (w2 * item2)) / (item1 + item2); print(result); }

17th Jun 2021, 2:51 AM
Tushar Jain
Tushar Jain - avatar
1 Answer
0
Don't know dart, but as it seems, stdin.readLineAync() returns a String. Looks like you need to convert the string input into number before you can do arithmetic operation on them.
4th Jul 2021, 1:31 AM
Ipang