Pages

Write a Simple Java Program

Writing a program involves designing a strategy for solving the problem and then using a programming language to implement that strategy. Let’s first consider the simple problem of computing the area of a circle. How do we write a program for solving this problem? Writing a program involves designing algorithms and translating algorithms into programming instructions, or code. An algorithm describes how a problem is solved by listing the actions that need to be taken and the order of their execution. Algorithms can help the programmer plan a program before writing it in a programming language. Algorithms can be described in natural languages or in pseudocode (natural language mixed with some programming code). 
The algorithm for calculating the area of a circle can be described as follows: 
1. Read in the circle’s radius. 
2. Compute the area using the following formula:
 area = radius * radius * p 
3. Display the result.


No comments:

Post a Comment