Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello! Quick question. Why won't this run? When I put it into a compiler it says that Error: Main method not found in class LetterInventory,
Hello! Quick question. Why won't this run? When I put it into a compiler it says that Error: Main method not found in class LetterInventory, please define the main method as: public static void main(String[] args)or a JavaFX application class must extend javafx.application.Application, or that there is no main method.
Java
| cd/ home/cg/root/63ec8dd04821a Error: Main method not found in class LetterInventory, please define the main method as: public class LetterInventory { public static void main(String[] args) public static final int LETTER = 26; or a JavaFX application class must extend javafx.application.Application import java, util, ; publie cless Letterlmentory (| public stetic final int LITTER - 26; privete int [] lettercount; private int letterhun; private int size; //Constructor. Takes the string, onalyzes the cheracters, and creates an int array whepe the / urber of each letter is kept. Only excepts letters, and all letters are converted to leaer / / enose public LetterImentory(String dato) f lettercount = new int [L[TTCR]; for (int 1=0;1=88 lettertum 825 ) \{ letterCount[lettertum] size +i ) /iketurns the size of the constructed erray, public int sireo f \} return size; / / iveluates if the constructed arpey is enpty. public boolean isinpty() f \} return ( size =0); //pre a Assures thot there are nurbers in the arpoy. //post: Returns the number of tires a given leteer oceured in the string. /Af a non alphobetie cheracter is passed, on Hilegald ararentixception is thormi. public int get(char letter) \{ har ch - Character, tolowercase(letter); if (ch>z11dh7a) f \} int nun = ch =e4; int total = letter[ount[nun]; return total; \} //pre there is a 26 elenent arpoy with a count for eoch lettor of the alphabet. //posti A stering of all the letters is returned in alphebntical erder, with equel nurber (l lekters that are in the ceigirel string. publie string tostring() f String result = " ["; for (int 11;i ' z ' 1 nemletter a1 value \& D) \{ throw nem Illegolargunent Exceptien(); \} if (lettercount [newLetter] > value) f size =- letter[ount[nembetter]; lettercount[nembetter] - value; size i= value; \} //pre t the elient hes 2 int erays they wish to oed toesther. //pesti A third Letterinventory thet is the sin of the first two is returned. public LetterImentory ada(Letterimentory other) \{ LetterImventory here - new LetternwentoryO; for (int t=i; LitTeR; i+1){ here. letterCount [i] - letterCount [i]+ other. letterCount [i]; y here, size = size + other, size; return here; \} //pre : The elient hes 2 int errays they wish to subtrect, //posti A third tetterinventory is returned that is the difference of the tho, /lif the result would be negetive, nutl is returned. public LetterImentory subtract(LetterImentory other) f Letterlmventory now = new LetterInventaryO; for (int i=1;i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started