Opcode
  • Opcode
Write a program in Java that converts meters, to feet without using any types of loops. What is did was create to methods, one for converting feet to meters, the other converting meters to feet. Then I used the incremental operator, and then printed out the variable each time. However the program did not format the variables to my liking how do I fix this?
Computer Science
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions.

Opcode
  • Opcode
Write a program in Java that converts meters, to feet without using any types of loops. What is did was create to methods, one for converting feet to meters, the other converting meters to feet. Then I used the incremental operator, and then printed out the variable each time. However the program did not format the variables to my liking how do I fix this?
Computer Science
schrodinger
  • schrodinger
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

Opcode
  • Opcode
I should mention I cannot use DecimalFormat, and the instructor want me to use something of "%4.3f" whatever that is.
anonymous
  • anonymous
You shouldn't need loops for converting units. All you need is numbers and multiplication. When your instructor is talking about %4.3f, they are talking about representing the decimal in a string. This is called string formatting. Here's a page from the documentation on it: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html. You should definitely read through it. Let's say you wanted to represent a float variable in a string, you would do the following. float pi = 3.1415927f; String output = String.format("Pi: %f", pi); Now let's say you wanted to set the precision to 3, you would do: String output = String.format("Pi: %.3f", pi); Everything else you need to know about formatting in Java is in that documentation. But here's a working solution for your problem: https://gist.github.com/AlexeyNosych/cb2fbd38d320219a8b47
Opcode
  • Opcode
Exactly what I was looking for, thank you.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

Looking for something else?

Not the answer you are looking for? Search for more explanations.