Write a java program to check whether the given number is prime number or not.

Answers
Aiesha if you need a clue its find a code equivalent for the operation of proving prime.Eg, (sorry again a little rusty code but here goes) when 'n' not 0; "prime" if 'n' divides by 1 and n only. Perhaps another line or 2 to cover all primes technically but that the point is, is a very accurate way to code a prime programme where 'In Alumni' it is very much a taboo area to be so confident as to technically be able to 100% get correct prime programme where there are many real logical arguments to say most common ways to code are evidently incorrect. Other areas which are unique and fascinating by fact in HE / Honorary study Aisha is the area of Dentistry and Optology where it is still decided by institute not award what exactly the level of Profession is with regards to medicine. IE, you may be an Dental Surgeon with a very low salary indeed or an Optologist (eye expert) without any sort of medical education.I mention this as it seems that you will not be a student forever on here wheras as a tutor I am and will be answering questions about Prime number programme or advanced calculus in my opinion limitlessly and it is important that you are referred to directions which will evidently be important for your level of education desired and professional employability in the long term. All the best, M Cover SE and Cambs.
mattcover
18 January 2018
Hi Aiesha,This answer assumes you are capable of writing the code itself but gives you an overview of the structure needed:First set up the program parameters (class etc.)Then define an integer which is to be the number to be checked, you can define it as a number in the code or as a user input.Attempt to divide the number by 2, 3, 4 etc, using a iteration to increase the value of the number you are dividing by each time.At the end of each loop, have the program check if the new number is an integer and is not 0 or 1. If this is true then have the program print that it is not a prime number and kill the program.If the output division equals 1 then have it read that it is a prime (since the loop must have increased the number to divide up to the value of the input number, meaning it is a prime).Hope that helps, I can give you a lesson on prime numbers if that would help.Kind regards,Tom
Tom M.
07 February 2018
public class PrimeExample{     public static void main(String args[]){      int i,m=0,flag=0;        int n=3;//it is the number to be checked      m=n/2;        if(n==0||n==1){     System.out.println(n+" is not prime number");        }else{     for(i=2;i<=m;i++){          if(n%i==0){           System.out.println(n+" is not prime number");           flag=1;           break;          }         }         if(flag==0)  { System.out.println(n+" is prime number"); }    }//end of else  }    }   
wintersoldier
04 March 2018
Add an answer

Similar questions

What does HTML stand for and do?


Hypertext Markup Language

As you can probably guess from the title, HTML stands for Hypertext Markup Language and is a language used by web browsers to interpret and represent text, images, videos, audio and other mediums for people on web pages. HTML defines the structure of a website while other technologies their appearance (CSS) and behaviour (JavaScript). "Hypertext" describes the links between pages of content on the web that you can access immediately by clicking on said link. "Markup" refers to the method by which text, images, and other content is annotated to then be displayed. Examples of the these markup elemetns include <head>, <title>, <body>, <header>, <footer>, <article>, <section>, <p>, <video>, <ul>, <ol>, <li> and many more.

What is HTML Used For?

HTML was first developed by physicist Tim Berners-Lee at CERN, the European Organization for Nuclear Research in 1990 when looking for a way that researchers could share documents with each other. This was the foundation of the World Wide Web. HTML allows people to create and design web pages using elements such as paragraphs, headings, links, quotes, images etc. It is not a programming language, so doesn't have a dynamic functionality, rather it helps to organize and format a page. It uses simple coding to denote how each part of the page should look. For example, you could create a paragraph by placing the relevant text within 2 tags <p> and </p>. HTML is now an official web standard which is monitored and developed by the World Wide Web Consortium (W3C

Urgent tutor help

I have an assignment on Java coding need help with it. The assignment detail is below :

The overall aim of this assignment is to implement a simple graphics tool. This must be built as a graphical application using the Java Swing and AWT classes. The software will allow users to type in simple commands which cause a “pen” to move around a virtual canvas area drawing lines as it moves. The final product should be a fully working application which includes a typical application window, containing a menu bar and supporting dialogue boxes.

As well as implementing a programmatic solution to the defined requirements, you are required to submit a graphical representation of your final solution as a Unified Modelling Language (UML) class model. This class model should show all classes used in your solution, along with all attributes and methods which you yourself have written. Although classes used from the Swing library should be shown there is no need to display their attributes and methods.

Requirement 1 – basic application

The first requirement is to develop a simple GUI which contains an outer window (frame), a canvas drawing area, a console type text input area, and a menu bar. The menu bar should contain at least a ‘File’ and a ‘Help’ menu. The ‘File’ menu should contain the options “New”, “Load”, “Save” and “Exit”. The ‘Help’ menu should contain an “About” option. The application window should be resizable by the user. For this first requirement the menu options should simply act as stubs, later requirements will provide the actual functionality. When selected each option should pop–up a dialogue saying that the option has been selected.

Requirement 2 – command support

The second requirement is to implement some basic commands to allow drawing. The users should be able to type in these commands within the console text area. The “New” menu option should cause the canvas to be cleared. The application should be able to spot invalid commands and report this to the user.

The commands to be supported are shown in the following table.

Command:Description penup: Lifts the pen from the canvas, so that movement does not get shown. pendown : Places the pen down on the canvas so movement gets shown as a drawn line. left : Turn the direction 90 degrees to the left. right : Turn the direction 90 degrees to the right. forward : Move forward the specified distance. back : Move backwards the specified distance. red : Sets the output pen colour to red. green: Sets the output pen colour to green. blue : Sets the output pen colour to blue. reset: Resets the canvas to its initial state.

.

Java Assignment

Hi. I am stuck on this question. Any help will be appreciated. The overall aim of this assignment is to implement a simple graphics tool. This must be built as a graphical application using the Java Swing and/or AWT classes. The software will allow users to type in simple commands which cause a virtual pen (sometimes it is also called a turtle after the Logo programming language which was popular in schools in the 1980s) to move around a virtual canvas area drawing lines as it moves. The final product should be a fully working application which includes a typical application window, containing a menu bar and supporting dialogue boxes. You should use GraphicsPanel.java inside your program. It sets up a canvas for you to draw on and displays a simple turtle. You can modify it as you see fit. Requirement 1 – basic application 20 marks The first requirement is to develop a simple GUI which contains an outer window (frame), a canvas drawing area, a console type text input area, and a menu bar. Themenu bar should contain at least a ‘File’ and a ‘Help’ menu. The ‘File’ menu should contain the options “New”, “Load”, “Save” and “Exit”. The ‘Help’ menu should contain an “About” option. The application window should be resizable by the user. For this first requirement the menu options can be blank and have no attached functionality, subsequent requirements will provide the actual functionality. When selected each option should pop–up a dialogue saying that the option has been selected. Program runs Panel for drawing is displayed You need to demonstrate that the panel can be drawn on (note if you have implemented subsequent requirements they will do this). Console text area Note this could be the console itself or some sort of component such as a TextArea or TextField. You need to demonstrate that text can be entered and minimally echoed back (note if you have implemented subsequent requirements they will do this). (5 marks) File Menu Items with pop ups for each New (1 mark) Load (1 mark) Save (1 mark) Exit (1 mark) Help Menu About (1 mark) UML Diagram (10 marks) Should show internal detail of your classes (including GraphicsScreen.java). Any Swing/AWT classes or other external classes should be shown as boxes only. Requirement 2 – command support 35 marks The second requirement is to implement some basic commands to allow drawing. The users should be able to type in these commands within the console text area. The “New” menu option should cause the canvas to be cleared. The application should be able to spot invalid commands and report this to the user. The commands to be supported are very explicit and MUST match those shown in the following table. The command must be typed in by the user and not selected from a menu as some of them will have parameters which MUST be typed with the command, for example “forward 90”. The parameters must not be entered separately, either after the command or in a separate text field. These commands must not be entered using separate textfields for command and parameter. When the program first runs the turtle/pen should be set to the middle of the canvas and point down the screen and the pen should be set to “down”. Hence if the first command was “forward 100” a line from the middle of the screen to nearer the bottom would be drawn. Requirement 3 – loading, saving and exiting. 20 marks The main aim of requirement three is to implement the remaining menu options. The “Load” and “Save” should allow the user to select a file name via a dialogue box. The current image should then be either loaded or saved to a file. If the user attempts to load a new image without the current one been saved first then a warning dialogue should be shown to the user, which should provide the opportunity for the current image to be saved first. The “Exit” and “About” menu options should also be completed. During exit a similar check should be made to see whether the user is attempting to exit without saving changes.

Assignment Help Please

Your boss at Innovations R Us, Rita Webb, has agreed to equip a selected work team with SMART devices. Instructions: 1. Rita asks you to prepare a report for the Purchasing Committee that will analyse the advantages and disadvantages of each type of device for the staff team to use. Relevant factors could be:  Specific features/advantages at least 2 devices relevant for a specific work team  Purchase price/budget considerations  Ongoing costs/future proofing  Information technology trends for business use  Need for staff training  Operability with existing operating systems/technology platforms e.g. Windows, iOS or Android  Other relevant issues such as types of software to be run 2. Innovations R Us is an authorised reseller of IT equipment. As the report author, you are free to make any realistic assumptions about this NZ based company and its operations. However the information presented about the appropriate technology, must be from actual acknowledged sources. E.g. online publications and web sites of similar businesses. 3. The report will need to come to some valid conclusions and make recommendations based on your investigation. 4. The report must be structured according to an acceptable format such as found at: http://www.monash.edu...ogy/report/1.3.3.xml and will include:  Cover page  Table of contents  Introduction  Relevant sections/subsections  Conclusions  Recommendations  Reference list/bibliography  Appendices (where relevant) 5. References must be formatted using APA (MS Word APA acceptable)