Closed

# Netbeans Java Programming Help Needed ASAP!

Tags:
Last response: in Applications
Share
January 22, 2013 6:31:26 AM

Need help with the following problem ASAP.

Problem:
Use netbeans to write a java program that prints the following expressions. Output the result of calculations not the literal value, when displaying the answers. (For instance display 7*5, not 12). Decimals should be displayed as shown.
The sum of 7 and 5 is 12
The product of 6 and 3 is 18
The square of 5 is 25.0
52 divided by 3.0 is 17.333
a b L Programming
January 22, 2013 9:30:18 AM

I'm scratching my head here. Am I the only person who sees the section in parentheses as a direct contradiction of the instruction preceding it (let alone the fact that 7*5 is not a sum)? It's amazing how the most trivial of academic exercises can be made complicated by people who can't word instructions clearly.

January 22, 2013 12:05:04 PM

Thank you! I was thinking the same thing about the instructions. To make it worse I can't get a response in what she really wants, super irritating but glad it wasn't just me seeing it that way. Thank you
Related resources
January 22, 2013 12:10:45 PM

I was thinking to set it up as System.out.println("7+5");
Then continuing for the next and the next, but then again that is sooo stupid easy that it makes me doubt that is what she wants. Per her instructions it says not the literal value which would display just 12 is not wanted, so don't set it up as a solved expression, agreed?
a b L Programming
January 22, 2013 3:03:32 PM

var A = 7;
var B = 5;
var C = 3;
var D = 6;
...
var product = C * D;
...
print product;
...

Make sure to use explicit typecasting.
January 22, 2013 6:50:50 PM

Found out how to do them in the proper format, now my issue is with the last two. I don't know how, or if, there is a proper way to do squares in that format? Also, how do you do placeholders? I know its System.out.printf as the opener, but I get confused on how you put the %.2f and where because I keep getting errors.
System.out.println("The sum of 7 + 5 is " + (7+5));
System.out.println("The product of 6 * 3 is " + (6*3));
System.out.println("The square of 5 is " + (5*5));
System.out.printf("52 / 3.0 is " + (52/3.0));
a b L Programming
January 22, 2013 8:08:20 PM

To properly compute a square root, you can use math.sqrt(x), with x being the number you want the square root of.

P.S. When dividing, the result is called the quotient.
February 1, 2013 10:52:08 PM