Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. for (rows = 0; rows < bandstand.length; rows++){
  2. System.out.print ("Please enter number of positions in row " + (char)(rows + (int) 'A'));
  3. columns = keyboard.nextInt();
  4. bandstand[rows] = new double [columns];
  5. while ( columns < 0){
  6. System.out.print ("ERROR: Out of range, try again:");
  7. columns = keyboard.nextInt();
  8. }
  9.  
  10. }
  11.  
  12. for (rows = 0; rows < bandstand.length; rows++){
  13. do {
  14. System.out.print ("Please enter number of positions in row " + (char)(rows + (int) 'A'));
  15. columns = keyboard.nextInt();
  16. } while (columns < 0);
  17. ...
  18.  
  19. for (rows = 0; rows < bandstand.length; rows++){
  20. System.out.print ("Please enter number of positions in row " + (char)(rows + (int) 'A'));
  21. columns = keyboard.nextInt();
  22. while (columns < 0) {
  23. System.out.print ("ERROR: Out of range, try again:");
  24. columns = keyboard.nextInt();
  25. }
  26. ...
  27. // note that array is created *after* columns is validated
  28.  
  29. for (rows = 0; rows < bandstand.length; rows++){
  30. System.out.print ("Please enter number of positions in row " + (char)(rows + (int) 'A'));
  31. columns = keyboard.nextInt();
  32. if (columns < 0) {
  33. System.out.println("Columns must be >= 0!");
  34. continue; // starts over for this row
  35. }
  36. ...
  37.  
  38. for (rows = 0; rows < bandstand.length; rows++){
  39. System.out.print ("Please enter number of positions in row " + (char)(rows + (int) 'A'));
  40. columns = keyboard.nextInt();
  41. while ( columns < 0){
  42. System.out.print ("ERROR: Out of range, try again:");
  43. columns = keyboard.nextInt();
  44. }
  45. bandstand[rows] = new double [columns];
  46.  
  47. }
  48.  
  49. for (rows = 0; rows < bandstand.length; rows++){
  50. System.out.print ("Please enter number of positions in row " + (char)(rows + (int) 'A'));
  51. columns = keyboard.nextInt();
  52. if(columns >= 0) {
  53. bandstand[rows] = new double [columns];
  54. }
  55. while ( columns < 0){
  56. System.out.print ("ERROR: Out of range, try again:");
  57. columns = keyboard.nextInt();
  58. }
  59.  
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement