View Single Post
  #1 (permalink)  
Old 12-13-2007, 12:46 PM
I-Shine I-Shine is offline
Member
 
Join Date: Dec 2007
Posts: 2
I-Shine is on a distinguished road
The highest number
The application is meant to ask for 10 numbers and print out the highest, here is what I have been able to do:

Code:
import java.io.*; public class ArrayExample { static BufferedReader kbRead = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { int numNames = getInt("Number of names? "); String[] names = new String[numNames]; for (int i = 0; i < names.length; i++) { names[i] = getString("Enter name #" + i); } for (int i = 0; i < names.length; ++i) { System.out.println(names[i]); } } public static int getInt(String prompt) throws IOException { System.out.print(prompt + " "); return Integer.parseInt(kbRead.readLine()); } public static String getString(String prompt) throws IOException { System.out.print(prompt + "The highest number is" + numNames); return kbRead.readLine(); } }
Reply With Quote
Sponsored Links