Thursday, March 12, 2020

A Calculator Example Program (With Java Code)

A Calculator Example Program (With Java Code) The following Java code is for a simple calculator. There are nine JButtons to represent the numbers 1 to 9, and three JButtons for addition, subtraction and totaling the result. A JTextField at the top keeps track of the numbers being pressed and the result of the arithmetic operation. Java Code The purpose of this Java program  is to show how to implement an  ActionListener  interface for handling JButton button  event  clicks by using the containing class, an inner class, and  an anonymous inner class. //Imports are listed in full to show whats being used //could just import javax.swing.* and java.awt.* etc.. import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.BorderLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.JButton; import java.awt.Container; public class SimpleCalc implements ActionListener{ JFrame guiFrame; JPanel buttonPanel; JTextField numberCalc; int calcOperation 0; int currentCalc; //Note: Typically the main method will be in a //separate class. As this is a simple one class //example its all in the one class. public static void main(String[] args) { //Use the event dispatch thread for Swing components EventQueue.invokeLater(new Runnable() { Override public void run() { new SimpleCalc(); } }); } public SimpleCalc() { guiFrame new JFrame(); //make sure the program exits when the frame closes guiFrame.setDefaultClo seOperation(JFrame.EXIT_ON_CLOSE); guiFrame.setTitle(Simple Calculator); guiFrame.setSize(300,300); //This will center the JFrame in the middle of the screen guiFrame.setLocationRelativeTo(null); numberCalc new JTextField(); numberCalc.setHorizontalAlignment(JTextField.RIGHT); numberCalc.setEditable(false); guiFrame.add(numberCalc, BorderLayout.NORTH); buttonPanel new JPanel(); //Make a Grid that has three rows and four columns buttonPanel.setLayout(new GridLayout(4,3)); guiFrame.add(buttonPanel, BorderLayout.CENTER); //Add the number buttons for (int i1;i10;i) { addButton(buttonPanel, String.valueOf(i)); } JButton addButton new JButton(); addButton.setActionCommand(); OperatorAction subAction new OperatorAction(1); addButton.addActionListener(subAction); JButton subButton new JButton(-); subButton.setActionCommand(-); OperatorAction addAction new OperatorAction(2); subButton.addActionListener(addAction); JButton equalsButton new JButton(); equalsButton.setActionCommand(); eq ualsButton.addActionListener(new ActionListener() { Override public void actionPerformed(ActionEvent event) { if (!numberCalc.getText().isEmpty()) { int number Integer.parseInt(numberCalc.getText()); if (calcOperation 1) { int calculate currentCalc number; numberCalc.setText(Integer.toString(calculate)); } else if (calcOperation 2 { int calculate currentCalc - number; numberCalc.setText(Integer.toString(calculate)); } } } }); buttonPanel.add(addButton); buttonPanel.add(subButton); buttonPanel.add(equalsButton); guiFrame.setVisible(true); } //All the buttons are following the same pattern //so create them all in one place. private void addButton(Container parent, String name) { JButton but new JButton(name); but.setActionCommand(name); but.addActionListener(this); parent.add(but); } //As all the buttons are doing the same thing its //easier to make the class implement the ActionListener //interface and control the button clicks from one place Override public void actionPerform ed(ActionEvent event) { //get the Action Command text from the button String action event.getActionCommand(); //set the text using the Action Command text numberCalc.setText(action); } private class OperatorAction implements ActionListener { private int operator; public OperatorAction(int operation) { operator operation; } public void actionPerformed(ActionEvent event) { currentCalc Integer.parseInt(numberCalc.getText()); calcOperation operator; } } }

Tuesday, February 25, 2020

Organizational Design Case Study Example | Topics and Well Written Essays - 750 words - 1

Organizational Design - Case Study Example The company gives a lot of freedom to its associates and all its employees are associates as they are stakeholders as well. There is no hierarchy and no boss and two instances have been given in which new staff have been asked to do what they felt should be done according to the opportunities and no formal work pan or functions were given. All new staff are first expected to know the working of the company and the various departments and divisions before settling down to his or her own work. The challenge and the central problems seems to be to examine how this no structure management system could be essentially tied with the profitability approach so that employees are able to provide their best performance and the company output is also improved. Among one of the challenges faced by the company was leaking of one of its popular waterproof product. The product clearly had some flaws and after a lot of research, this problem was solved and the innovativeness and flexibility of the co mpany have been responsible for overcoming difficult times.WL Gore & associates always maintained an open and unstructured corporate environment and despite having 5300 associates the company still maintains the policy of no hierarchy, yet leadership by all. Also all its plants and units have been kept small so that there is greater interaction and closely knit pattern of working. Everyone is encouraged to be innovative and although opportunities are provided no formal task are drawn to retain maximum flexibility of the work pattern.

Sunday, February 9, 2020

Managing capability Essay Example | Topics and Well Written Essays - 3000 words - 1

Managing capability - Essay Example The organizational capabilities are the typical analysis and assessment of the skills, potentials and the effort exhibited by the employees in the firm. The capabilities have the complete evaluation of the employees and the resources for the assurance of profitability and productivity. The organizational capabilities depend on the achievement of the organizational goals effectively and efficiently. The organizations play a vital role in routing these capabilities and they are the result of the interlinked routings. The analysis of the task is at ease in comparison with the creation of capability. The analysis starts with the questions related to the functioning, activities performed and the current performance. â€Å"The field of strategic management deals with understanding the ways how firms achieve competitive advantage and how they create superior value.† (Arndt, 2008). In this study the main aim is to identify the capability and how it is related to the competitive advant age, different tools and the frame work. The organization that is analyzed is Toyota, where the task is to identify the different capability and the contribution to the competitive advantage, and analyzing the different functional areas of them. â€Å"Toyota believe the potential for growth in our industry is extremely promising.† (Psabilla, 2007). The competitive advantage of the firm is the dependency of the firm on the revenue and the profitability of the firm. A firm is said to own competitive advantage when profit of the firm is greater than the average revenue. The aim of any business unit is to have a sustained competitive advantage. This is shown in fig-1 According to Michael porter, competitive advantages are of two types; they are the cost advantages and the differentiation advantages. The cost advantages are those when the firm is capable of marketing and selling the products with the same

Thursday, January 30, 2020

An Inconvenient Turth Essay Example for Free

An Inconvenient Turth Essay My reason for picking this topic is, because I would like to know more about global warming. What are the real danger`s that we are facing due to global warming? What can we do to stop the exceeding rapid rates of global warming? I would like to imform other about the new knowledge that I obtain on the subect of globle warming. Al Gore tell how people use to Think about global warming that the world was big enough and we would never have a problem. He also describes global warming as when the sun`s radiation comes in, in the form of light waves passing through earth atmosphere to heat the earth,and then it is re-radiated back into space in the form of infrared radiation, and some of the out going infrared radiation is trapped by the earth atmosphere and warms it. This thin layer of atmosphere is being thicken by all of the global warming pollution that`s being put up there. He speaks of Mr. Roger Revelle as the first person to propose measuring carbon dioxide in the earth`s atmosphere. After the first years of data he intuited what it meant for what was to come. He and a team of other designed the experiment in 1957 with the help of Mr. Charles David Keeling. they started sending these weather balloons up every day. The results of his measurements after only a few years it was startling. He drew the connections between the larger changes in our civilization, and this pattern that was now visible in the atmosphere of the entire plant, and then he projected into then future where this was headed unless we make some adjustments. Mount Kilimanjaro had icecaps 30 years ago. and now it has all melted. Mr. Lonnie Thompson, studies glaciers, and predicts there will be no more snows of Kilimanjaro within the next decade. Its also is happening in Glacier National Park, and all around the world the ice is now gone. He mentions about CO2 and temperature, when there is more carbon dioxide, the temperature gets warmer. He speak of this not so much as a political issue,but a moral issue. It is deeply unethical. He had a lots of faith in the democratic system that these finding would be compelling enough to cause a real change but they were n`t. He speak about when the oceans get warmer that cause stronger storms leading to a lots of big hurricanes and a all time record in the U.S. of tornado, and in Japan record set for typhoons. He contribute the changing of the season to global warming and changing nature plans. He also says that the burning of forests and brush fires causes more co2 to be pit into the air.what all of this means is our ability to a have a future to live in the earth. I really enjoy the movie The movie was very informing I got a better idea about what is happening around the world. I agree with Al Gore something must be done. It was amazing to me about how everything connect together like a domino effect. I picture in my mind how all these great mountains all around us is melting which is changing the temperature of the sea, which cause many of the world`s disaster by storms. Man is destroying himself. It makes me think can we go back where their was not a lots of invention that polluted our air. Can we truly find a solution to this mas, mass, mass, problem are have we went to far of no return. I think about the air we breathe and the water we drink. I remember only about 40 yrs.ago when I was ten years old, my grandmother showed me where I could drink out a spring it was so clean and beautiful and fresh tasting, I hate to think if I when back there to drink what kind of substance would be in that water now. Everything is being effected our food, the animal niches,and season is changing we can`t tell winter from fall or spring from summer and the insects can`t tell neither. If we have gone to far to stop all the problems, why not do, what we can do, to correct what we can, for the future of our life on the earth.

Wednesday, January 22, 2020

Terrorists Attack: a Media Analysis :: essays research papers

Terrorists Attack!!   Ã‚  Ã‚  Ã‚  Ã‚  February 26, 1993, the day that terrorists made the biggest attack on American soil to that point. It was early afternoon on a Friday, 12:18 pm to be exact, a car bomb ripped through the guts of the now infamous North World Trade Center twin tower. It happened very quickly, and without warning, normal people were simply going about their daily business, when all of a sudden, the building shook, the power went out, and smoke began to fill all 110 floors of the towers. Many wondered what had happened, had a plane struck the building, was it an earthquake? D, none of the above, some crazed maniac had decided to kill 5 people and injure many more just to get some point across.   Ã‚  Ã‚  Ã‚  Ã‚  This event graced the front page of newspapers and news magazines across the country, the New York Times was the newspaper closest to the action. Covrage in this newspaper was published one day after the event, and coverednot only the event but the ensuing traffic chaos it caused. Being a newspaper local to New York City, the site of the attack, the newpaper catered to the interests of its local readers. The New York Times, however, is also circulated around the country, and around the world. This required the newpaper editors, publishers, and writers to remain sensitive to the feelings and thoughts of readers in the broader reading audience.   Ã‚  Ã‚  Ã‚  Ã‚  Newsweek Magazine also published coverage of the attack. Their primary audience is a national one, and consequently, the coverage is geared toward a broader audience. Also, seeing as the magazine is only published once a week, rather than daily as the New York Times, Newsweek had more time to gather facts and evidence. This added time for research leads more to a fact based coverage than a question based coverage.   Ã‚  Ã‚  Ã‚  Ã‚  One interesting observation is that it seems both sources immediately assume that foreign terrorists were the primary perpetrators of this attack. Neither article comes right out and says it, however both are rather ambiguous about it. Newsweek does mention the possibility of a domestic source for the violence, but spends much more time and effort explaining the possible foreign sources. Overall both articles seem rather straightforward in their representation of the event, and remain rather simplistic, so as not to confuse the reading audience.   Ã‚  Ã‚  Ã‚  Ã‚  When an event of this magnitude occurs, emotions are bound to play a role in the coverage.

Monday, January 13, 2020

Math Ib Ia Sl

Jonghyun Choe March 25 2011 Math IB SL Internal Assessment – LASCAP’S Fraction The goal of this task is to consider a set of fractions which are presented in a symmetrical, recurring sequence, and to find a general statement for the pattern. The presented pattern is: Row 1 1 1 Row 2 1 32 1 Row 3 1 64 64 1 Row 4 1 107 106 107 1 Row 5 1 1511 159 159 1511 1 Step 1: This pattern is known as Lascap’s Fractions. En(r) will be used to represent the values involved in the pattern. represents the element number, starting at r=0, and n represents the row number starting at n=1. So for instance, E52=159, the second element on the fifth row. Additionally, N will represent the value of the numerator and D value of the denominator. To begin with, it is clear that in order to obtain a general statement for the pattern, two different statements will be needed to combine to form one final statement. This means that there will be two different statements, one that illustrates the numerators and another the denominators, which will be come together to find the general statement.To start the initial pattern, the pattern is split into two different patterns; one demonstrating the numerators and another denominators. Step 2: This pattern demonstrates the pattern of the numerators. It is clear that all of the numerators in the nth row are equal. For example all numerators in row 3 are 6. 1 1 3 3 3 6 6 6 6 10 10 10 10 10 15 15 15 15 15 15 Row number (n)| 1| 2| 3| 4| 5| Numerator (N)| 1| 3| 6| 10| 15| N(n+1) – Nn| N/A| 2| 3| 4| 5| Table 1: The increasing value of the numerators in relations to the row number.From the table above, we can see that there is a downward pattern, in which the numerator increases proportionally as the row number increases. It can be found that the value of N(n+1) – Nn increases proportionally as the sequence continues. The relationship between the row number and the numerator is graphically plotted and a quadratic fit determ ined, using loggerpro. Figure 1: The equation of the quadratic fit is the relationship between the numerator and the row number. The equation for the fit is: N= 0. 5n2+0. 5n or n2+n2, n>0 Equation 1 In this equation, N refers to the numerator.Therefore, N= 0. 5n2+0. 5n or n2+n2, n>0 is a statement that represents step 2 and also step 1. Step 3: In relation to table 1 and step 2, a pattern can be drawn. The difference between the numerators of two consecutive rows is one more than the difference between the previous numerators of two consecutive rows. This can be expressed in a formula N(n+1) – N(n) = N(n) – N(n-1) + 1. For instance, N(3+1) – N(3) = N(3) – N(2) +1. Using this method, numerator of 6th and 7th row can be determined. To find the 6th row’s value, n should be plugged in as 5 so that N(6) can be found.As for the 7th row’s numerator, n should be plugged in as 6. 6th row numerator is therefore: N(5+1) – N(5) = N(5) – N( 4)+1 N(6) – 15 = 15 – 10+1 N(6) = 15+6 N(6) = 21 7th row numerator is therefore: N(6+1) – N(6) = N(6) – N(5)+1 N(7) – 21 = 21 – 15 +1 N(6) = 42 – 15 + 1 N(6) = 28 Not only by this method, but from the equation found in step 2, figure 1, 6th and 7th row numerator can be found also. 6th row numerator: N(6)=0. 5? 62+0. 5? 6 N(6)=0. 5? 36+3 N(6)=21 th row numerator: N(7)=0. 5? 72+0. 5? 7 N(7)=0. 5? 49+3. 5 N(7)=28 Consequently, these are the values of numerators up to the 7th row. 1 1 3 3 3 6 6 6 6 10 10 10 10 10 15 15 15 15 15 15 21 21 21 21 21 21 21 28 28 28 28 28 28 28 28 Using the method in step 3 and equation 1 in figure 1, it is evident that the numerator in the 6th row is 21. Since both equations have brought same values, it can be concluded that equation 1 is a valid statement that demonstrates the pattern of the numerator.Equation 1 will be used later also, in order to form a general statement of the pattern of whole LACSAP Fract ions. Step 4: When examining the denominators in the LASCAP’S Fractions, their values are the highest in the beginning, decreases, and then increases again. For example, the denominators in row 5 are; 15 11 9 9 11 15. From this pattern, we can easily see that the equation for finding the denominator would be in a parabola form. Element | 0| 1| 2| 3| 4| 5| Denominator | 15| 11| 9| 9| 11| 15|The relationship between the denominator and the element number is graphically plotted and a quadratic fit determined, using loggerpro. Figure 2: This parabola describes the relationship between the denominator and element number. The equation for the fit is : D = r2 – nr+r0 . In this equation, r refers to the element number starting from 0, and r0 being the first denominator value in the row. n refers to the row number starting from 1. To see if this equation work, the 3rd denominator value in the 3rd row was measured. D = 22 – 3 ? 2+6 D = 4 – 6 +6 D = 4With this equat ion, it is evident that the 6th and 7th row denominator values can be found. We already know the first and last denominators from when numerators were found; which are 21 and 28. 6th row second and sixth denominator: D = 12 – 6 ? 1+21 D = 1- 6+21 D = 16 6th row third and fifth denominator: D = 22 – 6 ? 2+21 D = 4- 12+21 D = 13 th row fourth denominator: D = 32 – 6 ? 3+21 D = 9- 18+21 D = 12 7th row second and seventh denominator: D = 12 – 7 ? 1+28 D = 1- 7+28 D = 22 7th row third and sixth denominator: D = 22 – 7 ? +28 D = 4- 14+28 D = 18 7th row fourth and fifth denominator: D = 32 – 7 ? 3+28 D = 9- 21+28 D = 16 Now, since the denominators in the 6th and 7th row are found, the sixth and seventh rows can be drawn and added in the LACSAP’S Fractions. Consequently, these are the fractions up to the 7th row. 1 1 32 1 1 64 64 1 1 107 106 107 1 1 1511 159 159 1511 1 1 2116 2113 2112 2113 2116 1 1 2822 2818 2816 2816 2818 2822 1 Now th at the patterns for the LASCAP’S Fractions are found, all fractions can be expressed in the form En (r) when it is the (r+1)th element in the nth row, starting with r=0. The general statement of the pattern is clearly found when using the equations for the nominator and the denominator.Therefore, the general statement for En r will be En (r) = 0. 5n2+0. 5n r2 – nr+r0 In order to see if the equation works correctly, we can plug in number and figure out if the general statement works out. For example, E7 (3) = 2816 = 0. 5n2+0. 5n r2 – nr+r0 = 0. 5 ? (7)2+0. 5 ? (7) 32 – 7? 3+28 = 2816 . Here, it is clear that the formula is applicable. In order to make sure that the general statement is valid, finding the additional rows of the recurring sequence of fractions by using the general statement above would be useful.Here, I chose to settle on 2 additional rows which are the 8th and 9th rows in the pattern. 8th row numerator: N(8)=0. 5? 82+0. 5? 8 N(8)=0. 5? 64+4 N8=36 9th row numerator: N(9)=0. 5? 92+0. 5? 9 N(9)=0. 5? 81+4. 5 N9=45 8th row second and eighth denominator: D = 12 – 8 ? 1+36 D = 1- 8+36 D = 29 8th row third and seventh denominator: D = 22 – 8 ? 2+36D = 4- 16+36 D = 24 8th row fourth and sixth denominator: D = 32 – 8 ? 3+36 D = 9- 24+36 D = 21 8th row fifth denominator: D = 42 – 8 ? 4+36 D = 16- 24+36 D = 28 9th row second and ninth denominator: D = 12 – 9 ? 1+45 D = 1- 9+45 D = 37 9th row third and eighth denominator: D = 22 – 9 ? +45 D = 4- 18+45 D = 31 9th row fourth and seventh denominator: D = 32 – 9 ? 3+45 D = 9- 27+45 D = 27 9th row fifth and sixth denominator: D = 42 – 9 ? 4+45 D = 16- 36+45 D = 25 Thus, these are the fractions up to the 9th row. 1 1 1 32 1 64 64 1 1 107 106 107 1 1 1511 159 159 1511 1 1 2116 2113 2112 2113 2116 1 1 2822 2818 2816 2816 2818 2822 1 1 3629 3624 3621 3628 3621 3624 3629 1 1 4537 4531 4527 4525 4525 4527 4531 4537 1 This shows th at the general statement for the symmetrical, recurring sequence of fractions is valid and will continue to work.