anonymous
2013-01-21 20:06:49 UTC
The sum of 7 and 5 is 12
The product of 6 and 3 is 18
The square of 5 if 25.0
52 divided by 3.0 is 17.333
Here is my code thus far
System.out.print("The sum of 7 and 5 is ");
System.out.print(7+5);
System.out.println();
System.out.print("The product of 6 and 3 is ");
System.out.print(6*3);
System.out.println();
System.out.print("The sqaure of 5 is ");
System.out.print(Math.pow(5,2));
System.out.println();
System.out.print("52 divided by 3.0 is ");
System.out.print(52/3.0);
I know this does what I want it to, but my question is, How do I get the 17.333? My output is 17.33333332. And I know there is probably a way of simplifying this i.e. less lines needed, but sadly I wasn't paying attention in class and I dont have my book on me to look up it up.
Thanks