- println"Enter" Integer.toString(SENTINEL" to stop" while(true String hex = readLine"Enter a hexadecimal number" int n

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * File: HexToDecimalConverter.java * -------------------------------- * This program reads numbers from the user and converts them * from hexadecimal to decimal. * * Author: CS1MD3, Nov. 2008 */ import acm.program.*; public class HexToDecimalConverter extends ConsoleProgram { public void run() { println("This program converts hexadecimal to decimal.");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: println("Enter " + Integer.toString(SENTINEL) + " to stop."); while (true) { String hex = readLine("Enter a hexadecimal number: "); int n = Integer.parseInt(hex, 16); if (n == SENTINEL) break; println(hex + " hex = " + n + " decimal"); } } /* Sentinel constant */ private static final int SENTINEL = 0; }...
View Full Document

This note was uploaded on 10/27/2009 for the course COMP SCI 1MD3 taught by Professor Various during the Winter '07 term at McMaster University.

Ask a homework question - tutors are online