Characters
आपको पेज पर प्रिंट करने के लिए क्रियाओं (verbs) की एक सूची दी गई है, और आप जाँचना चाहते हैं कि आपके प्रिंटर में सभी अक्षर प्रिंट करने के लिए पर्याप्त इंक है या नहीं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
इंटरमीडिएट Java
अभ्यास निर्देश
conjugationArray में कितने शब्द हैं, यह निकालिए.- सही comparison ऑपरेटर चुनिए ताकि हम
tabLengthसे नीचे ही रहें. - हर रन के अंत में
iबढ़ाने के लिए उचित updating ऑपरेटर चुनिए. - वह वैरिएबल लिखिए जिससे हमें
conjugationसे हरwordमिल सके.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
class CharacterCounter {
public static void main(String[] args) {
String[] conjugation = {"hide", "hindered", "hiding", "hidden", "hindering", "hid", "hides", "hinder"};
// Retrieve the number of words in the array by calling the correct field
int tabLength = conjugation.____;
int numberOfCharacters = 0;
// Choose the appropriate operators (logical and increment)
for (int i = 0; i ____ tabLength; i____) {
// Give the proper variable to get each word out of conjugation
String word = conjugation[____];
numberOfCharacters += word.length();
}
System.out.println("There are " + numberOfCharacters + " characters in the list");
}
}