Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 8 years, 7 months ago. Active 8 years, 7 months ago.
Viewed 24k times. What are the mistakes you are seeing? Also the code as posted does not compile. This way, when reading your program maybe half a year later , you immediately see at the same place that celsius is a double number coming from some input.
Using two separate characters does the job in a more robust way. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Java Temperature Converter Ask Question. Asked 1 year, 6 months ago. Active 1 year, 6 months ago. Viewed times. Improve this question. Add a comment. Active Oldest Votes. Name this class ConversionCalculator.
Create a Scanner In order to interact with the user, a program must utilize a Scanner object. A Scanner object can read what a user types into the command line. This Scanner will read the numeric value the user wishes to convert, the units the user wishes to convert from, and the units the user wishes to convert to.
Note: Copy and paste the following line of code outside of the class declaration in order for Eclipse to recognize a Scanner object. Do the same for whatever units the user wants to convert to.
Note: It may be helpful to inform the user of legal values to enter. For instance, if your code is only built to handle "in" and not the full word "inches," then you should either edit your code to account for this or let the user know that "in" is the only legal input value. At this point, you must construct the two LengthConverter objects necessary to perform the unit conversion.
Print out a message that prompts the user to type the numeric value that is to be converted. HashSet Class In Java. Java LinkedHashSet. Java ArrayDeque Class. Java EnumSet. Java Iterator. List Iterator In Java.
Map Interfaces. Java SortedMap Interface. Java NavigableMap. Java Map. Entry Interface. Map Classes. Java HashMap Implementation. TreeMap In Java - java. Java WeakHashMap Class. Java IdentityHashMap.
Java EnumMap. Java Comparators. Collection Algorithms. Java Collection Algorithms. Java Read-only Collections And Algorithms. Java Singleton. Java nCopies Collections - Collections. Legacy Classes and Interfaces. Java Vector. Stack In Java - java. Stack Class. Java Dictionary Class - java. Java Hashtable. Java Properties Class - java. Properties Class. Collection Framework In Java. More Utility Classes. StringTokenizer In Java. Java BitSet. Java Date Class. Calendar In Java - java.
Calendar Class. Java GregorianCalendar. Java TimeZone Class. Java SimpleTimeZone. Locale Class In Java. Java Random Class - java. Random Package. Java Observable. Java Currency Class. Java Formatter Class. Java Formatter Methods. Java Formatter. Java Formatting Numbers. Usage Of java. Java Regular Expression. Alternative For list Method - listFiles Method. Java Stream Classes.
Byte Streams. Java InputStream Class. Java OutputStream Class. Java FileInputStream. Java FileOutputStream. Java ByteArrayInputStream. Java ByteArrayOutputStream. Java Filtered Byte Streams. Java Buffered Byte Streams. Java BufferedInputStream.
0コメント