0

i don't know what went wrong. i would apreciate any help

import java.util.Scanner; // this program will let you know the area of your cuboid public class Nexus { public static void main(String[]args) { Scanner dc = new Scanner(System.in) ; Scanner ac = new Scanner(System.in) ; Scanner xc = new Scanner(System.in) ; double length = dc.nextDouble(); double breadth= ac.nextDouble(); double height = xc.nextDouble(); double area = length*height*breadth; System.out.println(area); } }

31st Jan 2017, 3:29 PM
shobhit
shobhit - avatar
5 Respuestas
+ 5
I'd say that you don't need 3 scanners, just one (for example, "dc" --then remove ac and xc declarations), and in that one scanner, get nextDouble() three times, one for each dimension of your cuboid. [EDIT] An input scanner is a data flow that waits for data to be typed (or input via a file, for instance). You normally need one input scanner, then you keep on getting nextDouble, nextChar or whatever, until the data flow comes to an end (of file).
31st Jan 2017, 3:38 PM
Álvaro
+ 5
Try removing the extra scanners, they aren't single-use items. Keep calling nextDouble() from dc, remove ac and xc, report again if it still isn't working.
31st Jan 2017, 3:46 PM
Dao
Dao - avatar
+ 1
got it i have tried and now it works. thnx
31st Jan 2017, 3:47 PM
shobhit
shobhit - avatar
0
can u plz show me with an example
31st Jan 2017, 3:42 PM
shobhit
shobhit - avatar
0
u can take 3 scanner....but take the value after every object declaration
1st Feb 2017, 5:43 AM
Somnath Ghosh
Somnath Ghosh - avatar