Likes

Sem4 MT6


1.Define the following terms:

Purchase Order
Delivery Challan
Rejection Note
Goods Received Note
Goods Inwards Note
Ans:
i)Purchase Order - A document from the customer to the seller listing the required items and providing a description of the goods.
ii)Delivery Challan - A document that is sent with the shipment of goods. It lists the description, and quantity of the goods that are delivered.
iii)Rejection Note - A document that lists the materials that are rejected due to defects found during quality inspection. The reason of rejection is also included.
iv)Goods Received Note - A document that acknowledges that the materials have been inspected and accepted by the manufacturer.
v)Goods Inwards Note - A document that records the entries of the materials when they are received at the store of the organization.

2.Identify the various criteria for classifying an organization and discuss them in detail.

Ans:
An organization consists of a group of people working specifically to achieve a common goal. Organizations can be classified on the basis of nature of work, profitability, type of system, and ownership

i)Based on the Nature of Work:
Organizations can be classified depending on their nature of work as:

a)Manufacturing-based: Business organizations involved in producing tangible goods or products are called manufacturing organizations. b)Automobile manufacturing companies, iron and steel plants, and food and beverage processing units are examples of manufacturing organizations.
c)Service-based: Business organizations involved in providing services to other businesses or people, rather than producing tangible goods, are called service-based organizations. Airlines, hotels, hospitals, banks, and insurance agencies are examples of service organizations.
Based on Profitability:

ii)Organizations may be classified on the basis of their focus on profit. These organizations can be:

a)Profit-based organizations: The primary goal of these organizations is to increase their profit margin. These organizations try to increase the value of their share by increasing the value of the company stock.
b)Nonprofit-based organizations: These organizations do not have profit as their primary goal. They are usually involved with socially relevant issues. Some examples of nonprofit organizations include social groups, universities, human rights commissions, and worker unions.

iii)Based on the Type of System:
Based on the type of system an organization implements, it can be classified as simple or complex and adaptive or nonadaptive.

a)Simple or complex: A simple system consists of a lesser number of elements that interact with each other in a simple and uncomplicated manner. An eating joint is an example of a simple system, wherein the customer places an order, the ordered food is prepared, and the food is served to the customer.  Components in a complex system have a high level of interaction with each other. A car manufacturing organization is an example of a complex system.
b)Adaptive or nonadaptive: An adaptive organization is one that is able to change in response to the changes in the environment. For example, the fashion and cosmetics industries are highly dependent on external stimuli. A nonadaptive organization is one that is not able to change easily in response to external stimuli. For example, the automobile industry needs to take many factors into account before deciding on a change. These factors may include the cost of manufacturing a modified product or the availability of raw materials.

iv)Based on Ownership:
On the basis of the nature of ownership, business organizations can be classified into the following types:

a)Sole proprietorship: When one individual heads a business organization, it is said to be sole proprietorship.
b)Partnership: A partnership organization has two or more individuals conducting the business together. Corporation: A corporation is a legal entity conducting business with numerous owners.

3.Explain the following terms briefly:Test caseCollaborationGeneralizationJob shopsBatch processing

Ans:
i)Test case: A test case is a set of actions that is executed to examine whether or not the implemented code of the software system complies with the requirements stated by the customer. This helps you to validate the system functionality against system requirements. A test case developed for a particular function of the software system includes a set of test input, execution conditions, and expected results.
ii)Collaboration: UML provides specific modeling constructs, known as collaborations, to model a use case realization in the design phase. Collaboration is a collection of classes, interfaces, and sub-systems that interact with each other to achieve the functions of a use case. It can be represented by creating an oval with a dotted line.
iii)Generalization: The generalization relationship exists among the actors or use cases that have similar behavior and properties. Two actors or use cases are said to have a generalization relationship when the characteristics of one actor or use case can be derived from the characteristics of another actor or use case.
iv)Job shops: The Job shop production process involves the manufacturing of a wide variety of products in small numbers for a specific customer requirement. This production process is used to make a higher number of products as compared to projects. Job shops require general-purpose equipment that is flexible, because every product goes through a different sequence of processes. In job shops, resources are sometimes overloaded, while at other times, they may be idle. Examples of a job shop include manufacturing of special items, such as furniture.
v)Batch processing: The batch processing production process involves large-scale manufacturing of products on the same equipment. Every new product incurs additional setup costs that can be reduced by manufacturing more units in each cycle. Products are stocked and supplied based on customer demand. Batch processing caters to those products that are generic in nature. Therefore, general-purpose equipment is used. The process does not undergo many changes, but skilled workers are required to perform tasks. Examples of batch processing include book publishing, garment manufacturing, and pharmaceutical production.

4.Describe the class diagram and class notations used in UML. Explain the visibility of attributes and operations in a class diagram. Explain the syntax of attributes and operations in class diagrams.

Ans:
Class diagram and class notations used in UML

A class diagram is used to create a structural model of a software system. The structural model describes the static architecture of a system and helps the software developer to translate the system use cases into system design.

 UML provides a class notation to represent classes in class diagrams. The class notation has three compartments where the first compartment depicts the name of the class, the second compartment depicts the attributes of the class, and the third compartment depicts the operations of the class.You can use class notations to document the design of a system in accordance with the requirements identified during the requirements analysis phase.
Visibility of attributes and operations

It is vital to ensure that the data of your classes remain secure. For this, UML allows you to specify the visibility of the class attributes and operations, which controls the accessibility of these class members from other classes. UML provides the following four visibilities for the attributes and operations of a class:

i)+: Indicates that the attribute or operation is accessible to other classes. In other words, the attribute or operation is public.
ii)-: Indicates that the attribute or operation is inaccessible to other classes. In other words, the attribute or operation is private.
iii)#: Indicates that the attribute or operation in the base class is accessible to derived classes. In other words, the attribute or operation is protected.
iv)~: Indicates that the attribute or operation is accessible to the classes, which are within the same package.
Syntax of attributes in class diagrams

The attributes of a class follow certain syntax in the class diagrams. The syntax to depict an attribute in a class diagram is:

visibility name: type

The preceding syntax contains the following mandatory fields:

i)visibility: Specifies whether the attribute of the class is private, public, protected, or package.
ii)name: Indicates the name of the attribute. This is a mandatory field.
iii)type: This is an optional field. It specifies the data type of the attribute.
For example, the Name attribute of the Employee class can be represented as:

-Name: String

Syntax of operations in class diagrams

The syntax to represent an operation of a class in the class diagrams is:

visibility name (parameter-list): return-type

The preceding syntax contains the following fields:

i)visibility: Specifies whether the operation of the class is private, public, protected, or package.
ii)name: Indicates the name of the operation.
iii)parameter-list: Indicates the list of parameters for the operat.
iv)return-type: Represents the data type of the value returned by the operation. This field can take the null value when the operation does not return any value.
The parameters of an operation are denoted using the following syntax:

Parameter name: type

For example, the getName() operation of the Employee class can be represented as:

+getName(EmpId : int) : string

5.What is meant by logistics? Explain the activities involved in logistics planning (any two) in detail.

Ans:
Logistics is a business-planning framework. It involves planning for the movement and storage of materials and information from any point in the operational process to the final order-fulfillment stage. Organizations thrive on the effectiveness and efficiency of their operational strategies. An efficient logistics plan supports in implementing the organizational processes, such as production and sales and marketing, effectively.

Logistics planning involves the following activities:

Analyzing the core business processes

Analysis of the core business processes of an organization is important as the logistics activities differ depending on the nature of the business undertaken by an organization.

Some of the general processes for a typical manufacturing-based business organization include:

i)Purchasing of material
ii)Receiving the material
iii)Warehousing
iv)Controlling the inventory
v)Handling the material
vi)Shipping
vii)Making decisions for physical distribution

The distribution of products is an important activity for an organization and its customers. For example, in a manufacturing organization, the goods are typically moved from the Production department to the warehouses, where they are stored until they are sent to the dealers.
The main factors to be considered while making decisions for the physical distribution are:

The size, number, and location of warehouses
The mode of transport depending on the type of goods, distances, and weights
The work force to be employed or hired.
Deciding the location of facilities:

Whenever an organization wants a new factory, warehouse, shop, office or other facilities, it is important to identify a strategic location.

Most organizations evaluate the feasibility of the location of a facility, such as a production plant, based on the factors, such as:

i)The locations of competitors, suppliers, and customers
ii)Availability of skilled workforce in the area
iii)Costs pertaining to operations, wages, transport, and taxes
iv)Transport and services availability
v)Plans regarding future expansion, or globalization

6.What is a state machine diagram? Explain its various components.

Ans:
Before developing a software system, a developer must understand the various states through which a component goes from its creation to termination. For this, UML provides a state machine diagram. A state machine diagram represents the various states that an object goes through during its lifecycle in response to events. You need to model the behavioral aspects of a system by using state diagrams. Therefore, you create a state diagram for the objects that respond to events. The various constituents of a state diagram are states, events, and transitions.

i)A state depicts a condition of an object and the activities of an object during its lifecycle. An initial state is the starting state of an object and is represented as a dot. A final state is the end state of an object and is represented as a dot encircled by a ring.
ii)An event is an occurrence that triggers a change of state of an object. It signifies the receipt of a message that requests for an operation to be performed.
iii)A transition is a change of state of an object due to the occurrence of an event. For example, the state of customer complaint transitions from Open to Closed when the Complaint Resolved on Phone event occurs. Similarly, the state transitions from Open to Waiting when the Complaint Not Resolved on Phone event occurs and from Waiting to Closed when the Complaint Resolved Onsite event occurs.

7.What is a product? Explain the product life cycle in detail.

Ans:
A product is an article or a substance that is manufactured or produced by a company for sale. The main objective of a product is to make the customer feel satisfied or benefited after the purchase of the product. Before marketing a product, it is important to understand the life cycle of a product in the market. When a product is launched, the demand for it varies with time. There are different stages through which the product passes when it is introduced in the market. These stages comprise the product life cycle. The life cycle of a product starts when it is launched in the market till the time it remains in the market. This life cycle helps organizations in analyzing the product's impact on the organization's market share. The different stages of a product life cycle are: introduction, growth, maturity, and decline.

i)Introduction: This is the first stage when the product is introduced in the market. The main focus of the organization at this stage is to make the customer aware of the product and its benefits. For this, organizations invest more in advertising and other promotional strategies. The focus is not on revenue generation.
ii)Growth: At the growth stage, once the product is established in the market, more retailers and customers are attracted to it. At this stage, the organization maintains the quality and price of the product to attract more customers. This results in profits for the organization.
iii)Maturity: At the maturity stage, the sale of the product first reaches saturation in the market. The distribution of the product reaches to the fullest in the market, leaving minimum demand for the product. Thereafter, its sale starts declining. The primary goals of an organization at this stage are to maintain the market share and promote the product by differentiating it from competitors? product.
iv)Decline: At the decline stage, there is a rapid increase of competing products that may be better in quality and low in price. As a result, sales start declining and production volumes need to be reduced. The primary goal of an organization at this stage is to try maintaining the sale of the product by adding new features and reducing the cost. However, if the product is still incurring loss, the organization may discontinue the product.

8.What is meant by logistics? Explain the activities involved in logistics planning (any two) in detail.

Ans:
Logistics is a business-planning framework. It involves planning for the movement and storage of materials and information from any point in the operational process to the final order-fulfillment stage. Organizations thrive on the effectiveness and efficiency of their operational strategies. An efficient logistics plan supports in implementing the organizational processes, such as production and sales and marketing, effectively.

Logistics planning involves the following activities:

i)Analyzing the core business processes

ii)Analysis of the core business processes of an organization is important as the logistics activities differ depending on the nature of the business undertaken by an organization.

Some of the general processes for a typical manufacturing-based business organization include:

i)Purchasing of material
ii)Receiving the material
iii)Warehousing
iv)Controlling the inventory
v)Handling the material
vi)Shipping
vii)Making decisions for physical distribution

The distribution of products is an important activity for an organization and its customers. For example, in a manufacturing organization, the goods are typically moved from the Production department to the warehouses, where they are stored until they are sent to the dealers.
The main factors to be considered while making decisions for the physical distribution are:

i)The size, number, and location of warehouses
ii)The mode of transport depending on the type of goods, distances, and weights
iii)The work force to be employed or hired.
Deciding the location of facilities:

Whenever an organization wants a new factory, warehouse, shop, office or other facilities, it is important to identify a strategic location.

Most organizations evaluate the feasibility of the location of a facility, such as a production plant, based on the factors, such as:

i)The locations of competitors, suppliers, and customers
ii)Availability of skilled workforce in the area
iii)Costs pertaining to operations, wages, transport, and taxes
iv)Transport and services availability
v)Plans regarding future expansion, or globalization

9.Explain the various stages of marketing process.

Ans:
The stages of the marketing process are analyzing the need for a product, deciding upon the marketing strategy, implementing the marketing strategy, and monitoring the product.

i)Analyzing the need for a product: While analyzing the need for a product, organizations need to analyze the customer's requirements and its own capabilities to manufacture a product. While planning for the marketing strategy for a product, an organization must analyze whether it has sufficient funds to be able to manufacture and get sufficient returns.
ii)Deciding upon the marketing strategy: After the analysis of the customer requirements and market trends, an organization needs to decide upon its marketing strategy. This strategy requires a decision on the marketing mix as well as a target market for which the marketing mix is prepared. The marketing mix consists of variables that marketing managers can control in order to best satisfy customers in the target market.
iii)Implementing a marketing strategy: The plan prepared at the decision stage of the marketing process is implemented at this stage. The product is launched in the market and the planned promotional strategies are implemented to ensure customer awareness and sale of the product. The launch of a product includes the following activities:
a)Product performance is evaluated through tests and quality checks.
b)Final packaging is designed and ordered.
c)Sales channels are identified and established.
d)Product feedback is updated based on market feedback and analysis.
e)Product documentation is completed and finalized.
f)User documentation, operating manuals, advertisement materials, product brochures, marketing materials, press releases, website pages, and maintenance instructions are completed and ready to be distributed at the appropriate time.
g)A Production Readiness Review document is prepared. This document confirms that all preparations are completed and the product is ready for launch.
h)The new product is launched when the service, sales, and distribution channels are ready.
iv)Monitoring the product: The task of the marketing team does not get over with the launch of the product in the market. At this stage, an organization needs to collect regular feedback from customers regarding their likes, dislikes, and suggestions for improvement of the product.  At this stage, competitors and their similar products need to be monitored closely and the marketing strategy may need to be modified accordingly.

10.What is structural modeling? List any three UML diagrams for structural modeling and explain them briefly.

Ans
UML provides various modeling techniques to represent the framework of a software system. Each modeling technique contains a set of diagrams to represent the requirements and structure of the software system. The UML modeling techniques may be used for structural modeling and behavioral modeling. Structural modeling involves depicting the static features of the software system. It is used to represent how the components or elements exist in a system.

The various UML diagram for structural modeling are:

i)Class diagram: A class diagram represents a set of classes, interfaces, and their relationships. It describes the set of attributes and operations associated with each class and the relationships among the various classes.
ii)Object diagram: An object diagram represents an instance of a class diagram. It represents the properties of a particular instance of a class.
iii)Package diagram: A package diagram represents the interrelated classes and interfaces of the system in a package.  It helps in representing the various packages of a software system and the dependencies between them. It also gives a high-level impression of use case and class diagrams.
iv)Component diagram: A Component diagram combines packages or individual entities to form components. You can depict these components and their dependencies by using a component diagram.
v)Deployment diagram: A deployment diagram shows the physical placement of components in nodes over a network. A deployment diagram can be drawn by identifying nodes and components.

11.Explain the concept of production planning in brief. Discuss in detail about the MRP phase of production planning.

Ans:
Production planning is an integral part of the production process. It is the first step in the production process. Every manufacturing-based organization performs a set of operations for producing finished goods. Each operation in the production process of an organization must be systematically designed, planned, organized, and controlled.

Production planning:

i)Helps organizations to develop and implement strategies so that cost-effective goods are produced with minimum resources.
ii)Involves the systematic scheduling of workers, materials, and machines for manufacturing products efficiently, economically, and timely.

The different phases of production planning are:
1. Material requirement planning (MRP)
2. Selecting the production process

MRP is an inventory control process used to calculate the amount of raw materials required to manufacture a specific product. MRP involves reviewing the stock quantity of raw materials according to the quantity of products to be manufactured in a specific period. It then involves calculating the quantity of components and materials required to manufacture those items and identifying the supply of materials required for the scheduled production. MRP involves planning work orders and purchase requisitions and suggesting appropriate rescheduling of the current material plan by taking into account the actual delivery date of a product.
The main inputs of MRP are:
i)Master Production Schedule (MPS) shows the quantity of products to be manufactured in a specific period. It is a detailed manufacturing plan that determines the products a manufacturer has to produce within predefined timelines. During MRP, the estimated plan provided by MPS is translated into a detailed plan that specifies the schedule for material requirement and delivery.
ii)Bill of Materials (BOM) consists of the materials, parts, and components that are required to manufacture the product. During MRP, the BOM and MPS are used to calculate the amount of each material required.
The lead-time is the time between the placement of an order for a product and the actual date of delivery. Determining lead-time of raw materials is essential for a manufacturing company so that the finished goods can be delivered to the customer in a timely manner and any shortages can be handled before the production process starts.
iii)Inventory records provide a detailed list of all the items that are currently in stock. The information is stored in a tabular format. MRP uses these existing inventory records to calculate the net quantity of materials required from the supplier. The net quantity required is calculated by subtracting the existing inventory from the total materials required as per MPS.
The main outputs of MRP are:
i)Schedule for Orders: It provides guidelines to place an order depending on the lead-time.
ii)Purchase Orders: It is a buyer's document and is used to formalize a purchase transaction with a supplier. On acceptance by the supplier, it becomes a legally binding contract between the two parties and hence, it must specify all terms and conditions applicable to the contract.
iii)Reports: The information from MRP is processed to generate various reports, such as performance reports and inventory transactions.

Core Java MT Solved



1.Identify the features of New API (NIO).

Ans:
i)The new API works more consistently across platforms.
ii)It makes it easier to write programs that gracefully handle the failure of file system operations.
iii)It provides more efficient access to a larger set of file attributes.

2.Differentiate between checked and unchecked exceptions.

Ans:
Checked Exception:
i)Every class that is a subclass of Exception except RuntimeException and its subclasses falls into the category of checked exceptions.
ii)You must ?handle or declare? these exceptions with a try or throws statement.

Unchecked Exception:
i)java.lang.RuntimeException and java.lang.Error and their subclasses are categorized as unchecked exceptions.
ii)You may use a try-catch statement to help discover the source of these exceptions, but when an application is ready for production use, there should be little code remaining that deals with RuntimeException and its subclasses.

3.Explain public, static, and void keywords in the following statement: public static void main(String args[])

Ans:
i)public: The public keyword indicates that the method can be accessed from anyobject in a Java program.
ii)static: The static keyword is used with the main() method that associates the method with its class. You need not create an object of the class to call the main() method.
iii)void: The void keyword signifies that the main() method returns no value.

4.Identify the limitations of the java.io.File class.

Ans:
The java.io.File class has the following limitations:
i)Many methods did not throw exceptions when they failed, so it was impossible to obtain useful error messages.
ii)Several operations were missing (file copy, move, and so on).
iii)The rename method did not work consistently across platforms.
iv)There was no real support for symbolic links.
v)More support for metadata was desired, such as file permissions, file owner, and other security attributes.
vi)Accessing file metadata was inefficient?every call for metadata resulted in a system call, which made the operations very inefficient.
vii)Many of the File methods did not scale. Requesting a large directory listing on a server could result in a hang.
viii)It was not possible to write reliable code that could recursively walk a file tree and respond appropriately if there were circular symbolic links.

5.Identify the five classes of the java.util.concurrent package and explain any two classes.

Ans:
i)Semaphore: Is a classic concurrency tool.
ii)CountDownLatch: A very simple yet very common utility for blocking until a given number of signals, events, or conditions hold.
iii)CyclicBarrier: A resettable multiway synchronization point useful in some styles of parallel programming.
iv)Phaser: Provides a more flexible form of barrier that may be used to control phased computation among multiple threads.
v)Exchanger: Allows two threads to exchange objects at a rendezvous point, and is useful in several pipeline designs.


6.Steve has been asked to automate the Library Management System either in C++ or Java. Steve has chosen to develop the project in Java. Identify the reason.

Ans:
One of the major problem areas in most of the object-oriented languages, such as C++, is to handle memory allocation. Programmers need to explicitly handle memory in the program for its optimum utilization. To handle memory allocation, they use pointers that enable a program to refer to memory location of the computer. However, Java does not support pointers and consists of the built-in functionality to manage memory.


7.You have created a class with two instance variables.You need to initialize the variables automatically when a class is initialized. Identify the method that you will use you to achieve this. In addition, describe the characteristics of this method.

Ans:
You can initialize the variable by using the constructor. The characteristics of a constructor are:
-       A constructor has the same name as the class itself.
-       There is no return type for a constructor. A constructor returns the instance of the class instead of a value.
-        A constructor is used to assign values to the data members of each objectcreated from a class

8.Differentiate between interface and abstract class.

Ans:
1.The methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
2.Variables declared in a Java interface are by default final. An abstract class may contain non-final variables.
3.Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
4.Java interface should be implemented using keyword, implements; A Java abstract class should be extended using keyword, extends.
5.An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
6.A Java class can implement multiple interfaces but it can extend only one abstract class.
7.Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
8.In comparison with Java abstract classes, Java interfaces are slow as it requires extra indirection.



PSEUDOCODE

PSEUDOCODE STANDARD

Pseudocode is a kind of structured english for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax.  At the same time, the pseudocode needs to be complete.  It describe the entire logic of the algorithm so that implementation becomes a rote mechanical task of translating line by line into source code.
In general the vocabulary used in the pseudocode should be the vocabulary of the problem domain, not of the implementation domain.  The pseudocode is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized.  E.g.,
Extract the next word from the line (good)
set word to get next token (poor)Append the file extension to the name (good)
name = name + extension (poor)
FOR all the characters in the name (good)
FOR character = first to last (ok)
Note that the logic must be decomposed to the level of a single loop or decision. Thus "Search the list and find the customer with highest balance" is too vague because it takes a loop AND a nested decision to implement it. It's okay to use "Find" or "Lookup" if there's a predefined function for it such asString.indexOf().
Each textbook and each individual designer may have their own personal style of pseudocode. Pseudocode is not a rigorous notation, since it is read by other people, not by the computer. There is no universal "standard" for the industry, but for instructional purposes it is helpful if we all follow a similar style. The format below is recommended for expressing your solutions in our class.
The "structured" part of pseudocode is a notation for representing six specific structured programming constructs: SEQUENCE, WHILE, IF-THEN-ELSE, REPEAT-UNTIL, FOR, and CASE. Each of these constructs can be embedded inside any other construct. These constructs represent the logic, or flow of control in an algorithm.
It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.
SEQUENCE is a linear progression where one task is performed sequentially after another.
WHILE is a loop (repetition) with a simple conditional test at its beginning.
IF-THEN-ELSE is a decision (selection) in which a choice is made between two alternative courses of action.

Although these constructs are sufficient, it is often useful to include three more constructs:
REPEAT-UNTIL is a loop with a simple conditional test at the bottom.
CASE is a multiway branch (decision) based on the value of an expression. CASE is a generalization of IF-THEN-ELSE.
FOR is a "counting" loop.
SEQUENCE
Sequential control is indicated by writing one action after another, each action on a line by itself, and all actions aligned with the same indent. The actions are performed in the sequence (top to bottom) that they are written.
Example (non-computer)
Brush teeth
Wash face
Comb hair
Smile in mirror
Example
READ height of rectangle
READ width of rectangle
COMPUTE area as height times width
Common Action Keywords
Several keywords are often used to indicate common input, output, and processing operations.
Input: READ, OBTAIN, GET
Output: PRINT, DISPLAY, SHOW
Compute: COMPUTE, CALCULATE, DETERMINE
Initialize: SET, INIT
Add one: INCREMENT, BUMP
IF-THEN-ELSE
Binary choice on a given Boolean condition is indicated by the use of four keywords: IF, THEN, ELSE, and ENDIF. The general form is:
IF condition THEN
sequence 1
ELSE
sequence 2
ENDIF
The ELSE keyword and "sequence 2" are optional. If the condition is true, sequence 1 is performed, otherwise sequence 2 is performed.
Example
IF HoursWorked > NormalMax THEN
Display overtime message
ELSE
Display regular time message
ENDIF
WHILE
The WHILE construct is used to specify a loop with a test at the top. The beginning and ending of the loop are indicated by two keywords WHILE and ENDWHILE. The general form is:
WHILE condition
sequence
ENDWHILE
The loop is entered only if the condition is true. The "sequence" is performed for each iteration. At the conclusion of each iteration, the condition is evaluated and the loop continues as long as the condition is true.
Example
WHILE Population < Limit
Compute Population as Population + Births - Deaths
ENDWHILE
Example
WHILE employee.type NOT EQUAL manager AND personCount < numEmployees
INCREMENT personCount
CALL employeeList.getPerson with personCount RETURNING employee
ENDWHILE
CASE
A CASE construct indicates a multiway branch based on conditions that are mutually exclusive. Four keywords, CASE, OF, OTHERS, and ENDCASE, and conditions are used to indicate the various alternatives. The general form is:
CASE expression OF
condition 1 : sequence 1
condition 2 : sequence 2
...
condition n : sequence n
OTHERS:
default sequence
ENDCASEThe OTHERS clause with its default sequence is optional. Conditions are normally numbers or characters
indicating the value of "expression", but they can be English statements or some other notation that specifies the condition under which the given sequence is to be performed. A certain sequence may be associated with more than one condition.
Example 
        CASE  Title  OF
                Mr      : Print "Mister"
                Mrs     : Print "Missus"
                Miss    : Print "Miss"
                Ms      : Print "Mizz"
                Dr      : Print "Doctor"
        ENDCASE
Example 
        CASE  grade  OF
                A       : points = 4
                B       : points = 3
                C       : points = 2
                D       : points = 1
                F       : points = 0
        ENDCASE
REPEAT-UNTIL
This loop is similar to the WHILE loop except that the test is performed at the bottom of the loop instead of at the top. Two keywords, REPEAT and UNTIL are used. The general form is:
REPEAT
sequence
UNTIL condition
The "sequence" in this type of loop is always performed at least once, because the test is peformed after the sequence is executed. At the conclusion of each iteration, the condition is evaluated, and the loop repeats if the condition is false. The loop terminates when the condition becomes true. 

FOR
This loop is a specialized construct for iterating a specific number of times, often called a "counting" loop.  Two keywords, FOR and ENDFOR are used. The general form is:
FOR iteration bounds
sequence
ENDFOR
In cases where the loop constraints can be obviously inferred it is best to describe the loop using problem domain vocabulary.
Example
FOR each month of the year (good)
FOR month = 1 to 12 (ok)FOR each employee in the list (good)
FOR empno = 1 to listsize (ok)

NESTED CONSTRUCTS
The constructs can be embedded within each other, and this is made clear by use of indenting. Nested constructs should be clearly indented from their surrounding constructs.
Example
SET total to zero
REPEAT
READ Temperature
IF Temperature > Freezing THEN
    INCREMENT total
END IF
UNTIL Temperature < zero
Print total
In the above example, the IF construct is nested within the REPEAT construct, and therefore is indented. 
  

INVOKING SUBPROCEDURES
Use the CALL keyword. For example:
CALL AvgAge with StudentAges
CALL Swap with CurrentItem and TargetItem
CALL Account.debit with CheckAmount
CALL getBalance RETURNING aBalance
CALL SquareRoot with orbitHeight RETURNING nominalOrbit


EXCEPTION HANDLING

    BEGIN 
        statements 
    EXCEPTION 
        WHEN exception type 
            statements to handle exception
        WHEN another exception type 
            statements to handle exception
    END 



Sample Pseudocode

"Adequate"

FOR X = 1 to 10 

    FOR Y = 1 to 10 
        IF gameBoard[X][Y] = 0 
            Do nothing 
        ELSE 
            CALL theCall(X, Y) (recursive method) 
            increment counter                  
        END IF
    END FOR
END FOR

"Better"
Set moveCount to 1
FOR each row on the board 
    FOR each column on the board 
        IF gameBoard position (row, column) is occupied THEN 
            CALL findAdjacentTiles with row, column
            INCREMENT moveCount 
        END IF 
    END FOR
END FOR

(Note: the logic is restructured to omit the "do nothing" clause) 


"Not So Good"
FOR all the number at the back of the array
    SET Temp equal the addition of each number
    IF > 9 THEN
        get the remainder of the number divided by 10 to that index
        and carry the "1"
    Decrement one
Do it again for numbers before the decimal
"Good Enough (not perfect)"
SET Carry to 0
FOR each DigitPosition in Number from least significant to most significant
    COMPUTE Total as sum of FirstNum[DigitPosition] and SecondNum[DigitPosition] and Carry  
    IF Total > 10 THEN
        SET Carry to 1
        SUBTRACT 10 from Total
    ELSE
        SET Carry to 0
    END IF
    STORE Total in Result[DigitPosition]
END LOOP  
IF Carry = 1 THEN
    RAISE Overflow exception
END IF




"Pretty Good"  This example shows how pseudocode is written as comments in the source file. Note that the double slashes are indented.
public boolean moveRobot (Robot aRobot)
{
    //IF robot has no obstacle in front THEN
        // Call Move robot
        // Add the move command to the command history
        // RETURN true
    //ELSE
        // RETURN false without moving the robot
    //END IF
}
Example Java Implementation
  • source code statements are interleaved with pseudocode.
  • comments that correspond exactly to source code are removed during coding.

public boolean moveRobot (Robot aRobot)
{
    //IF robot has no obstacle in front THEN
    if (aRobot.isFrontClear())
    {
        // Call Move robot
        aRobot.move();
        // Add the move command to the command history
        cmdHistory.add(RobotAction.MOVE);
        return true;
    }
    else // don't move the robot
    {
        return false;
    }//END IF
}
  



Document History
DateAuthorChange
12/2/03JDAdded Exception Handling and more examples
2/21/03JDAdded "problem domain vocabulary" paragraph.
Modified FOR loop explanation.



Loop: if we want to print all result then insert o/p box in loop…
           if aggregate want to print then put o/p box out of the loop…

Pseudo code:
  1.  "//" is used to represent the Comment.
  2. "begin ...end" use to start and end the Pseudo code.
  3. "accept"  use to accept Input.
  4. "display" print Output.
  5. "if…. else" use to make decision.
  6. "repeat… un-till"




Pseudo code coding: Example

begin
numeric ' n num1, n num2, n sum'. (Variable)
Display 'enter first number'
Accept 'n num1'
Display 'second number'
Accept 'n num2'
n sum=n num1+n num2
Display' the sum is '+n sum..(+ concatenate operrator)
End


Q.1: Write  Pseudo code that accept temperature in Celsius. Convert it into Fahrenheit and then displays the result ?

c/5=(f-32)/9

begin
numeric ntemp,nres
display 'enter temp in celsius'
accept 'ntemp'
nres=(9/5*ntemp)+32
display 'the temp in Fahrenheit is'+nres'.
end


Pseudo code: Product of two numbers…...

begin
numeric 'nnum1,nnum2,nproduct'(variable)
display 'enter first number'
accept 'nnum1'
display 'enter second number'
accept 'nnum2'
nproduct= nnum1*nnum2
display 'the product ' *nproduct'
end



Begin
Character cname
Display'enter name'
Accept cname
Display'Hello+cname'
end


Which  on is largest?
begin
nummeric nnum1,nnum2,nnum3,nnum4,nnum5,ntemp
display 'enter five number'
accept nnum1,nnum2,nnum3,nnum4,nnum5
If nnum1>nnum2
begin
ntemp=nnum1
end
begin
ntemp=nnum2
end
if nnum3>ntemp
begin
ntemp=nnum3
end
else
begin
if ntemp<nnum4
begin
ntemp= nnum4
end
end
if nnum5>ntemp
begin
nnum5=ntemp
end
display'the largest number'+ntemp
end


Write a pseudocode to find out the percentage of a student in five subject and give him grade according to the following norms…
If %>= 90 Grade A
      >= 75              B
      >= 60              C
      =< 60              D

Begin
Numeric nnum1, nnum2, nnum3, nnum4,nnum5,nsum,npercentage,ntotal
Character, cname
Display'name of the student'
Accept'cname'
Display'enter number of five subject'
Accept 'nnum1,nnum2,nnum3,nnum4,nnum5.'
nsum=nnum1+nnum2+nnum3+nnum4+nnum5
npercentage=(nsum/ntotal)*100
IfNpercentage >=90
begin
Display cGarde_A
end
Else
begin
If Npercentage>= 75
end
Begin
Display cgrade_B
End
Else
begin
ifNpercentage>= 60
end
Begin
Display cgrade_c
end
Else
Begin
Npercentage=<60
Begin
Display cgrade_d
End
End


Begin
Numeric nmarks,ntotal,navg,nctr
Nmarks=0
Ntotal=0
Navg=0
Nctr=0
Repeat
Begin
Enter'display the number of a student'
Accept nmarks
Ntotal=ntotal+nmarks
Nctr=nctr+1
End
Untill(nctr==30)
Navg=ntotal/30
Display the the avg marks of student'+navg'
end