Вы находитесь на странице: 1из 13

IT PROJECT BY: AQUEEL RAJKUMAR DARION PERSAD GEOVANI RAM THRISTON POON RENADO PARIA

DEFINITION: This is a condition based statement in Pseudocode that tells the program to perform a certain task when data inputted is true to the condition in the statement. SYNTAX: IF (condition) THEN begin Line of code Line of code End; OR IF (condition) THEN begin Line of code Line of code End; ELSE Line of code Line of code End;

PROBLEM 1: Create a program to accept a number. When the number is greater than 60,display Big Number", otherwise display Small Number

VAR num:Integer Begin Output Enter a number Input num IF (num > 60) THEN Output Big Number IF (num <= 60) THEN Output Small Number End.

(PLEASE NOTE: instead of using 2 separate IF statements, An IF THENELSE statement could be used, as shown in the Syntax)

PROBLEM 2:Create a program to accept three item prices, using these items, display either sufficient funds or insufficient funds, if the user is using $100.00

VAR total, price 1,price 2,price 3: real Begin Output Enter price: Input price 1 Output Enter price 2: Intput price 2 Output Enter price 3: Input price 3 total := price 1+price 2 +price 3 Output total= ,total IF (total > 100) THEN Output Non-Sufficient Funds End; ELSE Output Sufficient Funds End.

(PLEASE NOTE: A calculation was used in this program, but CANNOT be used in an IF statement. Also make note of the use of ELSE)

PROBLEM 3: Create a program to accept 3 whole numbers, when these numbers are entered, display a menu that would allow the user to select 3 different options: Option 1: would add all the numbers Option 2: would show the squares of the numbers Allow the program to use the 3rd option to exit the Program and tell the user he is exiting the program.

Keyword- Exit;

VAR Integer: a, b, c, choice, sum, sq1, sq2, sq3 Begin Output: enter 1st number: Input a Output enter 2nd number: Input b Output enter 3rd number: Input c Output menu Output 1. Add Output 2. Find squares Output 3. Exit Output Enter 1, 2, or 3 : Input choice

IF( choice = 1) THEN Begin Sum := a+b+c Output Sum= , sum End; IF (choice = 2) THEN Begin sq1 := a*a sq2 := b*b sq3 := c*c Output square of , a = , sq1 Output square of , b =, sq2 Output square of , c = , sq3 End; IF (choice =3) Then Output Exiting Program Exit; End.

PROBLEM 4: Create a program to accept 3 integer values: a, b, and c. when each integer is entered, display the type of angle it is; acute,, right, obtuse, straight, and reflex, when all 3 angles are entered, display the type of triangle it is; isosceles, scalene, equilateral, right angled, or not a triangle.

VAR a, b, c, total : integer Begin Output enter an angle: Input a IF ( a >0) AND (a< 90) THEN Output a is acute IF (a = 90) THEN Output a is a right angle IF (a>90) AND (a <180) then Output a is obtuse IF (a = 180) THEN Output a is a straight angle IF (a >180) AND (a< 360) then Output a is reflex (REPEAT FOR B AND C) Sum := a+b+c IF (sum = 180) then

Begin IF (a=60) AND (b=60) AND (c=60) THEN Output equilateral triangle IF (( a<>b) AND (b<>c) AND (a<>c)) AND (( a<> 90) AND (b<> 90) AND (c<> 90)) THEN Output scalene triangle IF (a=90) XOR (b=90) XOR (c=90) THEN Output Right angle triangle IF ((a=b) XOR (b=c) XOR (a=c) THEN Output isosceles triangle IF (sum <> 180) THEN Output Not a Triangle End.

Вам также может понравиться