Programs use selection statements to choose among alternative courses of action. For example,
suppose that the passing grade on an exam is 60. The pseudocode statement
If student’s grade is greater than or equal to 60
Print “Passed”
Pseudocode is an informal language that helps you develop algorithms without having to
worry about the strict details of Java language syntax. The pseudocode we present is particularly
useful for developing algorithms that will be converted to structured portions of Java programs.
Pseudocode is similar to everyday English—it’s convenient and user
Pseudocode is similar to everyday English—it’s convenient and user
friendly, but it’s not an actual computer programming language. You’ll see an algorithm
written in pseudocode.
Pseudocode does not execute on computers. Rather, it helps you “think out” a program
before attempting to write it in a programming language, such as Java.
determines whether the condition “student’s grade is greater than or equal to 60” is true.
If so, “Passed” is printed, and the next pseudocode statement in order is “performed.” (Remember,
pseudocode is not a real programming language.) If the condition is false, the
Print statement is ignored, and the next pseudocode statement in order is performed. The
indentation of the second line of this selection statement is optional, but recommended,
because it emphasizes the inherent structure of structured programs.
The preceding pseudocode If statement may be written in Java as
public class Apples {
public static void main(String[] args){
int studentGrade = 70;
if ( studentGrade >= 60 )
System.out.println( "Passed" );
}
}
good luck trying it , thank you.
we are going explain next ,
If .... else....
Good class , enjoying it !!
ReplyDelete