Results 1 to 5 of 5
 09072013, 11:05 PM #1Member
 Join Date
 Sep 2013
 Posts
 2
 Rep Power
 0
Please Help me! I have worked in this project for more than 12 hours!!!!
Java Code:public class JProgramTwo { public static void main(String[] UpRight) { //DECLARE VARIEBLES and ASSIGNNING VALUES! int Radius, Height, Edge, Lenght, Width, SideA, SideB, SideC, A, B, C, D, E, F, VSph, VCyl, VCub, VBox, Alg1, Alg2, ATri ; 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. Lenght = 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 VSph = (4.0)/(3.0)*(Math.PI)*Radius*Radius*Radius; VCyl = Math.PI*Radius*Radius*Height; VCub = Edge*Edge*Edge; VBox = Lenght*Width*Height; Alg1 = 1.0*(A*B + C)/(D + E*F); Alg2 = 1.0*(A + B)/(C + D); ATri = 0.25*Math.sqrt( (SideA+SideB+SideC)*(SideB+SideCSideA)*(SideA+SideCSideB)*(SideBSideC+SideA) ); //THE VOLUME OF THE SPHERE! System.out.format("The volume of a sphere with given Radius = " + VSph + "\n\n"); //cylinder System.out.format("The volume of the cylinder with given Radius and Height = " + VCyl + "\n\n"); //CUBE! System.out.format("The volume of a cube with a given Edge = " + VCub + "\n\n"); //BOX System.out.format("The volume of the box with given Lenght, Width, Height = " + VBox + "\n\n"); //ALGEBRAIC EXPRESSioNS System.out.format("The expression (AB+C)/(D+EF) = " + Alg1 + "\n\n"); System.out.format("The expression (A+B)/(C+D) = " + Alg2 + "\n\n"); //TRIANGLE! System.out.println("The area of the triangle with three given sides = "+ ATri + "\n\n\n\n\n\n\n" ); } }
This output displays the numbers to 12+ decimal places. Please, please help me. I have worked on this for 12 hours and I have not gotten the desired results. The numbers must have three decimal places only and they must be rightjustified. Please help me.
 09082013, 01:09 AM #2Member
 Join Date
 Sep 2013
 Posts
 4
 Rep Power
 0
Re: Please Help me! I have worked in this project for more than 12 hours!!!!
Check the API documentation for String.format() and follow the link to the explanation of the format string. Although there is more than one way, the easiest for you is probably to convert your value to a string and then use the format() method.
 09082013, 01:33 AM #3Member
 Join Date
 Sep 2013
 Posts
 2
 Rep Power
 0
 09082013, 08:42 AM #4Member
 Join Date
 Sep 2013
 Posts
 4
 Rep Power
 0
Re: Please Help me! I have worked in this project for more than 12 hours!!!!
I think no one is going to do your homework for you although people are willing to point you in the right direction. If you look at String (Java 2 Platform SE 5.0) you will easily see how to create a string and then you can see the explanation for the format method as I suggested.
 09082013, 05:59 PM #5Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 4,573
 Rep Power
 7
Re: Please Help me! I have worked in this project for more than 12 hours!!!!
System.out is an instance of PrintStream. So check the PrintStream API to see how to use format. You are not using it correctly. It is absolutely critical that you learn to read and understand the API documentation. Otherwise you will definitely struggle learning Java.
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
Similar Threads

have any one worked in json
By javastuden in forum Java ServletReplies: 0Last Post: 01152013, 08:19 AM 
Simple Project 4 or 5 Hours – Pay $100
By billaaa777 in forum Jobs OfferedReplies: 0Last Post: 08302008, 12:45 AM
Bookmarks