Facebook
From Adjowa Asamoah, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 115
  1. char[] populate(int numCharacters) {
  2.   // Check if the number of characters is within the specified range
  3.   if (numCharacters < 11 || numCharacters > 59) {
  4.     println("Number of characters should be between 11 and 59");
  5.     return null;
  6.   }
  7.  
  8.   char[] array = new char[numCharacters];
  9.   for (int i = 0; i < numCharacters; i++) {
  10.     array[i] = char(floor(random(97, 123))); // Random character from 'a' to 'z' in ASCII
  11.   }
  12.   return array;
  13. }
  14.  
  15. void setup() {
  16.   size(600, 200);
  17.   int numCharacters = 12; // Change to your chosen value
  18.   char[] randomCharacters = populate(numCharacters);
  19.   if (randomCharacters != null) {
  20.     textAlign(CENTER, CENTER);
  21.     textSize(20);
  22.     for (int i = 0; i < randomCharacters.length; i++) {
  23.       text(randomCharacters[i], 20 + i * 20, height / 2);
  24.     }
  25.   }
  26.   save("Assignment7_part1.png");
  27. }
  28.