Please assist with Java code....

closed account (18RGNwbp)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 public static void main(String[] args) {
        System.out.println("\n\t\t   VENTURA COUNTY COMMUNITY COLLEGE DISTRICT");
	System.out.println("\t\t\t\t Ventura College\n\n");
	System.out.println("\t\t\t\t     CS V40");
	System.out.println("\t\t\t\t Beginning Java\n\n\n");
	System.out.println("\t\t\t\t Juan Hernandez\n\n\n");

	//DECLARE VARIEBLES and ASSIGNNING VALUES!
	double Radius, Height, Edge, Length, Width, SideA, SideB, SideC, A, B, C, D, E, F, VSphere, VCylinder, VCube, VBox, ExpressionOne, ExpressionTwo, TArea;
	Radius = 5; //this is for the sphere.
	Height = 4; //use this one for the volume of the cylinder.
	Edge   = 6; //Use this for the volume of the cube.
	Length = 3; //box.
	Width  = 7; //box.
	Height = 8; //box.
	SideA  = 6; //triangle side.
	SideB  = 6; //triangle side.
	SideC  = 1; //triangle side.
	A      = 8; //fractions
	B      = 3; //fractions
	C      = 4; //fractions
	D      = 2; //fractions
	E      = 1; //fractions
	F      = 9; //fractions

        VSphere = (4.0)/(3.0)*(Math.PI)*Radius*Radius*Radius;
        VCylinder = Math.PI*Radius*Radius*Height;
        VCube = Edge*Edge*Edge;
        VBox = Length*Width*Height;
        ExpressionTwo = 1.0*(A + B)/(C + D);
        ExpressionOne = 1.0*(A*B + C)/(D + E*F);
        TArea = 0.25*Math.sqrt((SideA+SideB+SideC)*(SideB+SideC-SideA)*(SideA+SideC-SideB)*(SideB-SideC+SideA));
	//THE VOLUME OF THE SPHERE!
	System.out.printf("The volume of a sphere with given Radius                = " + "%.3f\n\n", VSphere);
   
	//The Volume of the cylinder
	System.out.format("The volume of the cylinder with given Radius and Height = " + "%.3f\n\n", VCylinder);
	//THE VOLUME OF THE CUBE!
	System.out.format("The volume of a cube with a given Edge                  = " + "%.3f\n\n", VCube);
	//THE VOLUME OF THE BOX
	System.out.format("The volume of the box with given Length, Width, Height  = " + "%.3f\n\n", VBox);
	//ALGEBRAIC EXPRESSioNS
	System.out.format("The expression (AB+C)/(D+EF)                            = " + "%.3f\n\n", ExpressionOne);
	System.out.format("The expression  (A+B)/(C+D)                             = " + "%.3f\n\n", ExpressionTwo);
	//THE AREA OF THE TRIANGLE!
	System.out.format("The area of the triangle with three given sides         = " + "%.3f\n\n\n\n\n\n\n", TArea);
    }
}

/* The output will display answers up to 15 digits... The answers are to have a decimal accuracy of three places and they must be aligned.  Please help a beginner programmer.  I barely started learning Java and barely know C++ */ 










closed account (Dy7SLyTq)
i dont know the answer but just in case no one saw the question... hes asking how to format the text so it aligns and can make it print only three decimals of a 15 decimal value
closed account (18RGNwbp)
Yes, DTSCode is correct.
closed account (Dy7SLyTq)
a quick look on google found that java has a printf similar to the c version, which you can use

http://docs.oracle.com/javase/tutorial/java/data/numberformat.html
closed account (18RGNwbp)
I already read this ... it is not helping at all. I tried using those things but it has not worked at all.
closed account (Dy7SLyTq)
what do you mean? thats the perfect thing... it allows you to size text and set precision
Topic archived. No new replies allowed.