Monday, October 21, 2019

Using the Switch Statement for Multiple Choices in Java

Using the Switch Statement for Multiple Choices in Java If your Java program needs to make a choice between two or three actions, an if, then, else statement will suffice. However, the if, then, else statement begins to feel cumbersome when there are a number of choices a program might need to make. There are only so many else...if statements you want to add before the code begins to look untidy. When a decision across multiple options is required, use the switch statement. The Switch Statement A switch statement allows a program the ability to compare the value of an expression to a list of alternative values. For example, imagine you had a drop-down menu that contained the numbers 1 to 4. Depending on which number is chosen, you want your program to do something different: //lets say the user picks number 4int menuChoice 4;switch (menuChoice){ case 1: JOptionPane.showMessageDialog(null, You chose number 1.); break; case 2: JOptionPane.showMessageDialog(null, You chose number 2.); break; case 3: JOptionPane.showMessageDialog(null, You chose number 3.); break; //This option gets chosen because the value 4 matches the value of //the menuChoise variablecase 4:Â  JOptionPane.showMessageDialog(null, You chose number 4.);Â  break; default: JOptionPane.showMessageDialog(null, Something went wrong!); break;} If you look at the syntax of the switch statement you should notice a few things: 1. The variable containing the value that needs to be compared to is placed at the top, inside the brackets. 2. Each alternative option starts with a case label. The value to be compared against the top variable comes next, followed by a colon. For example, case 1: is the case label followed by the value 1 - it could just as easily be case 123: or case -9:. You can have as many alternative options as you need. 3. If you look at the above syntax, the fourth alternative option is highlighted - the case label, the code it executes (i.e., the JOptionPane) and a break statement. The break statement signals the end of the code that needs to be executed. If you look, youll see that every alternative option ends with a break statement. Its very important to remember to put in the break statement. Consider the following code: //lets say the user picks number 1int menuChoice 1;switch (menuChoice)case 1: JOptionPane.showMessageDialog(null, You chose number 1.);case 2: JOptionPane.showMessageDialog(null, You chose number 2.);break;case 3: JOptionPane.showMessageDialog(null, You chose number 3.); break;case 4: JOptionPane.showMessageDialog(null, You chose number 4.); break;default: JOptionPane.showMessageDialog(null, Something went wrong!); break;} What you expect to happen is to see a dialog box saying You chose number 1, but because there is no break statement matching the first case label, the code in the second case label also gets executed. This means the next dialog box saying You chose number 2 will also appear. 4. There is a default label at the bottom of the switch statement. This is like a safety net in case none of the values of the case labels match the value being compared with it. Its very useful to provide a way of executing code when none of the desired options are chosen. If you always expect one of the other options to be chosen, then you can leave out the default label, but to put one at the end of every switch statement you create is a good habit to get into. It might seem unlikely that it will ever be used but mistakes can creep into the code and it can help to catch an error. Since JDK 7 One of the changes to the Java syntax with the release of JDK 7 is the ability to use Strings in switch statements. Being able to compare String values in a switch statement can be very handy: String name Bob;switch (name.toLowerCase()){ case joe: JOptionPane.showMessageDialog(null, Good morning, Joe!); break; case michael: JOptionPane.showMessageDialog(null, Hows it going, Michael?); break; case bob: JOptionPane.showMessageDialog(null, Bob, my old friend!); break; case billy: JOptionPane.showMessageDialog(null, Afternoon Billy, hows the kids?); break; default: JOptionPane.showMessageDialog(null, Pleased to meet you, John Doe.); break;} When comparing two String values, it can be a lot easier if you make sure they are all in the same case. Using the .toLowerCase method means all the case label values can be in lowercase. Things to Remember About the Switch Statement The type of the variable to be compared against must be a char, byte, short, int, Character, Byte, Short, Integer, String, or enum type. The value next to the case label cannot be a variable. It has to be a constant expression (e.g., an int literal, a char literal). The values of the constant expressions across all the case labels must be different. The following would result in a compile-time error: switch (menuChoice){ case 323: JOptionPane.showMessageDialog(null, You chose option 1.); break; case 323: JOptionPane.showMessageDialog(null, You chose option 2.); break; There can only be one default label in a switch statement. When using an object for the switch statement (e.g., String, Integer, Character) make sure it is not null. A null object will result in a runtime error when the switch statement is executed.

Sunday, October 20, 2019

Book Censorship and Banning of Childrens Books

Book Censorship and Banning of Childrens Books Many people think that book censorship, challenges and book banning are things that happened in the distant past. That is certainly not the case. You may also remember all of the controversy about the Harry Potter books in the early 2000s. Why Do People Want to Ban Books? When people challenge books it is generally out of a concern that the contents of the book will be harmful to the reader. According to the ALA, there are four motivating factors: Family ValuesReligionPolitical ViewsMinority Rights. The age level for which a book is intended does not guarantee that someone wont try to censor it. Though the emphasis seems to be on challenges to childrens and young adult (YA) books some years more than others, attempts are also continually mounted to restrict access to certain adult books, often books that are taught in high school. Most complaints are made by parents and are directed to public libraries and schools. The First Amendment to the U.S. Constitution The First Amendment to the U.S. Constitution states, Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances. The Fight Against Book Censorship When the Harry Potter books came under attack, a number of organizations joined together to establish Muggles for Harry Potter, which became known as kidSPEAK and focused on being a voice for kids in fighting censorship in general. KidSPEAK stressed, Kids have First Amendment rights- and kidSPEAK helps kids fight for them! However, that organization no longer exists. For a good list of organizations that are dedicated to fighting book censorship, just take a look at the list of sponsoring organizations in my article about Banned Books Week. There are more than a dozen sponsors, including the American Library Association, National Council of Teachers of English, American Society of Journalists and Authors and the Association of American Publishers. Parents Against Bad Books in Schools PABBIS (Parents Against Bad Books in Schools), is just one of a number of parent groups around the country challenging childrens and young adult books in classroom teaching, and in school and public libraries. These parents go beyond wanting to restrict access to certain books for their own children; they seek to restrict access for other parents children as well in one of two ways: either by getting one or more books removed from the library shelves or having access to the books restricted in some way. What Do You Think? According to article Public Libraries and Intellectual Freedom on the American Library Association Web site, while it is important and appropriate for parents to oversee their childrens reading and media exposure, and the library has many resources, including booklists, to assist them, it is not appropriate for the library to serve in loco parentis, making judgement calls appropriate for parents in terms of what their children do and do not have access to rather than serving in their capacity as librarians. For More Information About Book Banning and Kids Books ThoughtCo addresses the issue in the article Censorship and Book Banning in America about the controversy surrounding the teaching of the Adventures of Huckleberry Finn in an 11th Grade American Literature class. Read What Is a Banned Book? and how to save a book from banning by ThoughCo  to learn how you can prevent book censorship.

Saturday, October 19, 2019

Polish migration to United Kingdom Research Paper

Polish migration to United Kingdom - Research Paper Example The system of wages in the United Kingdom is prominently higher than many of the states in European Union and also those states which are not parts of European Union. This paper is aimed to analyse and explicate the impact of Polish migration to United Kingdom under the free movement policy of the European Union on the economy of United Kingdom. It also presents the description of migrations to the United Kingdom and its impact on its economy. Lastly, this paper also provides recommendation for the United Kingdom to remain a part of European Union or to withdraw from it in concordance with the analysis of the economy and Polish migrations to United Kingdom. European Union and Free Movement Law European Union is a transnational political and economic union consisting twenty eight members primarily from Europe. The operations of European Union are conducted through supranational institutions which are independent. The decisions of European Union are finalized after intergovernmental ne gotiations with all of the member states (Thomson 3-9). On these bases, the legislation for free movement of persons, immigrations and asylums has been passed with mutual consent of every state in European Union. This policy of free movement is the basic principle of the Treaty in article 45. The Treaty is based on the functioning of the European Union. ... He would not be required to take the work permit to work in the migrated country and he can also be a resident of that country for the purpose of work. According to this policy, a person can stay in the migrated European Union state after the end of his employment with the right to have an equal amount of treatment as the nationals of that state enjoy. This includes access to employment in any field, the working conditions of the organization where the immigrant has been employed and every other social or financial advantage (European Commissions para. 2). Immigration to United Kingdom The United Kingdom has been one of the most favourite countries for the asylum seekers and migration mostly from former colonies such as India, Caribbean, Pakistan, Kenya, South Africa and Hong Kong. After the enactment of British nationality Act in 1981, the immigration to the United Kingdom has substantially elevated not only from non-European Union countries but also from the countries which are mem bers of European Union (BBC 5-10). As mentioned in the introductory paragraph of this paper, the United Kingdom is a member state of European Union. The free movement of workers has played a significant role in the increase of immigrations to the United Kingdom from the member states of European Union (BBC 9-10). According to a report from BBC, there were 567,000 individuals who arrived to live in United Kingdom out of which 371,000 left. Despite of this, the total inward migration to the United Kingdom was 196,000 in 2009 (BBC UK para. 1). In 2006, the number of approved citizenship is 154,095 from which the applications received were 149,035 for British citizenship. The major groups from the granted citizenships

Friday, October 18, 2019

Close Analysis of Citizen Kane Assignment Example | Topics and Well Written Essays - 750 words

Close Analysis of Citizen Kane - Assignment Example Strong backlighting is applied in making the characters appear anonymous to the viewers; for example, when Kane is told that Mariah has been packing the entire morning. Smoke was filled in a room to illustrate the light beams that emanate from the projectors and the lamps. Cinematography utilizes great composition. This is effectively through mirror reflection. The reflection shows, analysis of the life of the characters, and also illustrating adequately composed image. The mirror enables the camera to illustrate several reflections of the characters. The inventive application of lighting and shadow in the film shows a genre that has dark and moody environment to illustrate mysterious and violent scenes. Like the scene where Kane tries in vain to convince Susan to stay. Classical Hollywood narrative is a concept applied in film history. The narrative illustrates both visual and sound techniques for developing motion pictures and production techniques in the American film sector, during the period â€Å"golden age of Hollywood.† Citizen Kane is classic film; this is because it was produced during the â€Å"golden age of Hollywood.† Classical film style applies the continuity editing principle. This is because the sound recording and the camera do not concentrate on themselves. In Citizen Kane, the cameras also focus on the background, like the several statues at the beginning of the clip. The classical narration has psychological motivation. This illustrates the human character will, towards a given goal. Kane illustrates the great desire to convince Susan not to leave. But, Susan has made up her mind to leave, despite the pleas of Kane. Classical Hollywood narrations have continuous time flow. The flow is only interrupted during flashback. Flashback is applied in Citizen Kane to show the memory sequence. Classical Hollywood overcomes the two

Analysis of competitiveness of Chinese textile in EU market Essay

Analysis of competitiveness of Chinese textile in EU market - Essay Example The paper tells about the entry of China in the world market since 2005, with the quota-benefits is instrumental in her rising position as an important player in the world market with cutting edge of competitiveness and higher standards. Clark observes in his study of international competitiveness the need for the management and organization to work in harmony. â€Å"Management and organization is the focal point of Clark’s study. It is the force of international competitiveness that creates incentive for change. A government can create temporary incentives but can do little to get domestic firms optimize their objective functions in the long run†. The study conducted by Caves indicates that producers behaviour and resource allocation are altered by trade changes, rate of adjustment of the structure of the manufacturing. Industries to import competition and the amount of the sunk capital are highly correlated, marketing opportunity at a global scale enhances the plant-s cale economies, and the product differentiation changes the effect of import competition.Collis advocates a different approach saying â€Å"that an appropriate industrial policy corrects market imperfections and creates congenial environment for successful business. To adopt suitable industrial policy, it is essential to clearly define industry’s role, understand company’s strategies in the light of shifting comparative advantage and the changing structure of the global industries, identify market failures and implement coherent policies to minimize the pitfalls.†

Thursday, October 17, 2019

Jails and Prisons Essay Example | Topics and Well Written Essays - 750 words

Jails and Prisons - Essay Example (Champion, 151) The defendants who are kept in jails are individuals who have to serve a sentence for misdemeanor offenses, felons who have to do jail time as a condition of their probation and people who are awaiting trial and cannot make bail .(Bergman & Berman, 2008 ). Jails are also used to temporarily detain juveniles pending transfer to juvenile authorities. They are also used to retain mentally ill patients until they are sent to appropriate mental health institutions. .( Carlson and Garrett, 2007) Jails sometimes run community programs as alternatives to incarceration. Jails also hold offenders who are in contempt of court, are crime witnesses and are in protective custody. They also hold convicted felons who are going to be sent to state prisons.(Carlson and Garrett, 2007). Jails generally do not give emphasis to how inmates behave following release. There are exceptions e.g. alcoholic treatment programs and domestic violence programs that seek to reduce the likelihood of repeated domestic violence. However their prime focus is on safely managing people. (Goldstein, 2006). Prisons are long term confinement facilities housing felony offenders and parole violators serving sentences greater than one year. The federal and state government run such establishments and nowadays even private companies are allowed to take up the contracts for running prisons. (Caputo, 2004). Compared to jails, prisons are typically larger and range in custody level from minimum security to maximum security where the nation's most dangerous criminals are confined. (Caputo, 2004). Prisons are self sufficient and self contained. These self contained facilities have recreational yards, workout rooms, auditoriums for viewing feature films and small stores for the purchase of toiletries and other goods. (Champion, 2007) The functions of a prison according to Champion are to provide societal protection, punish offenders, rehabilitate offenders and reintegrate offenders by preparing them for reentry into society through vocational and educational training ,counseling and other institutional measures.(Champion , 2007) Provisions for death penalty are in place in state and federal prisons .Federal prisons may be minimum or maximum security. Maximum security prisons hold 52 percent of all state of all state prisoners .These are built to house dangerous criminals and to prevent them from harming security guards are one another. Minimum security prisons on the other hand have more freedom of movement, privileges and contact with the outside world . However it is the medium security prisons that hold 37 percent of all state prisoners. (Sellers, 1993) References: Bergman, P and Berman, S.( 2008). The Criminal Law Handbook: Know Your Rights, Survive the System. Berkeley, CA: NOLO Carlson. M. and Garrett, J. S. (2007) Prison and Jail Administration: Practice and Theory . Gaithersburg, MD: 2nd ed : Aspen Publishers. Caputo , G. (Oct 2004) Intermediate Sanctions in Corrections. USA: University Of North Texas Press

Nationald Gallery Essay Example | Topics and Well Written Essays - 2500 words

Nationald Gallery - Essay Example The works blend with the design and architecture of The New Art Gallery enhancing the visitor's experience of the works by showing them in new and interesting ways and making connections between old and new art. However, local artistic styles were not lost completely and they make up an essential element of the mature English Romanesque style. In religious painting, this is characterized by the use of abstracted or distorted figures, which are fully coloured and delineated by solid outlines. Frederick Antal (1962) The area above the door itself provides the artist with a large semicircular field called the tympanum within which to carve both decorative and narrative subjects, which are supplemented by ornament applied to the door jambs, arches, and capitals. These carvings are often highly imaginative and amusing blending in some religious and secular imagery within one small area. Compositions are generally formal and patterned, while physical space is indicated by rectangular background panels. Exaggerated facial expressions and gestures portray religious drama scenes. Numerous illuminated manuscripts made for the new monasteries, seemingly indicate an essential element of the Norman establishment. Azzopardi (2001) The most unique collection includes paintings, drawings, sculpture, photographs, video and installations from artists and public and private collections in Britain and abroad. Major works are included by Francis Bacon, Per Barclay, Cecil Beaton, Bruce of LA; this exhibition highlights the artist's preoccupations with urban and natural landscapes and with human perception and interaction. Encompassing large-scale video and sound installation, photography, drawing and film, it gives a first UK staging to a number of newly-completed works. Office Architects, the exhibition includes a wealth of historical and contemporary drawings alongside models, collage, computer modelling and extracts from films. While many of these ideas were intended to enthuse and convince clients about real architectural schemes, some were private fantasies, exploring how the world might have looked today had the tastes of our predecessors been different. The collection of art includes works by Robert Adam, Archigram, Sir Charles Barry, Etienne-Louis Boullee, Sir William Chambers, Foster & Partners, Future Systems, Erno Goldfinger, Eric Mendelsohn, John Nash, Softroom, Paolo Soleri and Tecton. This art includes work painted of a dramatic floor-ceiling projection recreating the artist's ascent up a thirty-five metre deep Antarctic crevasse - together with a recent commission, Sky Drawing (Night, Day), which focuses on the movement of air traffic over Birmingham. Until recently the society has been developing collaboration with Vivid, Birmingham and includes work commissioned by Vivid with the support of the Henry Moore Foundation. Infected by Gina Czarnecki and Iona Kewney is a haunting video installation about the nature of the physical body in the context of future technological possibilities, seen through dance and digitally manipulated imagery. Men in the Wall by Liz Aggiss and Billy Cowie are a four screen, 3-dimensional stereoscopic installation. Each life-size 3D 'frame' is inhabited by a man whose world is tightly choreographed and scripted. Viewers can experience the men's shared, framed lives