ReadStrings - { final int MAX = 20; StringTooLongException...

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

View Full Document Right Arrow Icon
//******************************************************************** // ReadStrings.java Author: Lewis/Loftus // // Solution to Programming Project 8.1 //******************************************************************** / import java.util.Scanner; i public class ReadStrings { //----------------------------------------------------------------- // Creates an exception object and possibly throws it. //----------------------------------------------------------------- public static void main (String[] args) throws StringTooLongException
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { final int MAX = 20; StringTooLongException problem = new StringTooLongException ("String has too many characters"); String input = ""; System.out.println("Enter strings, enter DONE when finished:"); Scanner sc = new Scanner (System.in); while (!input.equals("DONE")) { input = sc.nextLine(); if (input.length() > MAX) throw problem; } System.out.println("Program successfully completed"); } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online