Monday's Programming Question
Today's programming question is all about converting Strings to numbers. The Double and Integer wrapper objects both have methods that are capable of converting a String value. The Java program to write this week will need to employ those methods.
Write a program that inputs a String from a user. The String will be a series of numbers each separated by a space (e.g., "11 2 36.4 4 8.9 7.6 3 256"). Convert the String into the series of numbers that it represents and add them all together. Finally display the result to the user. To make things a little more interesting allow for the String to include octal and hexadecimal literals (e.g., "11 2 0xEF 36.4 4 8.9 0647 7.6 3 256").
To test the program use the following String: "56.7 0.8 345 0xEFF 8.99 126 0647 73 5.67".


No comments yet. Leave a Comment