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); } }
5 ответов
+ 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).
+ 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.
+ 1
got it i have tried and now it works. thnx
0
can u plz show me with an example
0
u can take 3 scanner....but take the value after every object declaration