Inverted Triangle And Hello Program-Computer Programming-Assignment Solution, Exercises of Aeronautical Engineering

This is solution to assignment for Aeronautical Engineering and Computer Programming course. It was submitted to Prof. Chitraksh Gavde at Biju Patnaik University of Technology, Rourkela. It includes: Hello, Modify, Triangle, Invert, Ada, Text, Algorithm, Line, Spider, Set, Move, Stop

Typology: Exercises

2011/2012

Uploaded on 07/20/2012

savitri_122
savitri_122 🇮🇳

4.6

(14)

184 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
C2 Solutions
1. Modify the “Hello” program shown in class (Lecture C2) to display the following text
on the screen:
Hello World
My name is Your Name
Compiling: c:/docume~2/joeb/desktop/16070/concep~1/hello_world.adb (source file time stamp: 2003-09-
10 08:55:28)
1. -----------------------------------------------------
2.
3.
4.
5.
6. ------------------------------------------------------
7.
8.
9. with Ada.Text_Io;
10.
11. procedure Hello_World is
12.
13. begin -- Hello_World
14.
15. Ada.Text_Io.Put(Item => "Hello World ");
16. Ada.Text_Io.New_Line;
17. Ada.Text_Io.Put(Item => "My Name is Joe B");
18.
19. end Hello_World;
19 lines: No errors
2. There are two errors that are seen:
i. “raised SCREEN.WIN32_FILL_SCREEN_ERROR : screen.adb:99” is seen when the
output is redirected to the file.
ii. “raised SPIDER.HIT_THE_WALL: spider.adb:224” is seen when the output is only
displayed on the screen
3. Write an algorithm to use the Feldman “spider package” to draw an inverted triangle as
shown below. Turn in a hard copy of your code listing and an electronic copy of your
code.
RRRRRRR
R R
R R
R
docsity.com
pf3

Partial preview of the text

Download Inverted Triangle And Hello Program-Computer Programming-Assignment Solution and more Exercises Aeronautical Engineering in PDF only on Docsity!

C2 Solutions

1. Modify the “Hello” program shown in class (Lecture C2) to display the following text

on the screen:

Hello World

My name is Your Name

Compiling: c:/docume~2/joeb/desktop/16070/concep~1/hello_world.adb (source file time stamp: 2003-09- 10 08:55:28)



  1. with Ada.Text_Io;
  2. procedure Hello_World is
  3. begin -- Hello_World
  4. Ada.Text_Io.Put(Item => "Hello World ");
  5. Ada.Text_Io.New_Line;
  6. Ada.Text_Io.Put(Item => "My Name is Joe B");
  7. end Hello_World;

19 lines: No errors

2. There are two errors that are seen:

i. “raised SCREEN.WIN32_FILL_SCREEN_ERROR : screen.adb:99” is seen when the

output is redirected to the file.

ii. “raised SPIDER.HIT_THE_WALL: spider.adb:224” is seen when the output is only

displayed on the screen

3. Write an algorithm to use the Feldman “spider package” to draw an inverted triangle as

shown below. Turn in a hard copy of your code listing and an electronic copy of your

code.

RRRRRRR

R R

R R

R

Problem Analysis:

The inverted triangle consists of 4 lines with the following features:

i. The top line consists of 7 symbols with no gaps between them

ii. The following lines have (n-1) blanks spaces, followed by a symbol, followed

by (7-2n) blanks spaces and one symbol (if 7-2n > 0)

Algorithm:

1. Face the spider East

2. Set Spider color to Red

3. Move spider East 7 steps

4. for I in 2 .. 4 loop

i. Set Spider color to None

ii. Set Spider direction to South

iii. Move Spider 1 step

iv. Set Spider direction to West

v. Move Spider 7 steps

vi. Set Spider direction East

vii. Move spider (I-1) spaces

viii. Set Spider color to Red

ix. Move spider one step in the same direction as last move

x. Set Spider color to Black

xi. Move spider (n-2*I) steps

xii. If (n-2*I) > 0 then

1. Set Spider color to Red

2. Move one step

3. Set Spider color to none

4. move I-1 steps

5. Stop program execution

Compiling: c:/docume~2/joeb/desktop/adatex~1/pset1~1/spider_triangle.adb (source file time stamp: 2003- 09-10 10:28:10)

  1. with Spider;
  2. procedure Spider_Triangle is

  3. --| Program : This program demonstrates display an inverted triangle.
  4. --| Programmer : Joe B
  5. --| Date Last Modified : 09/10/

  6. N : Integer;
  7. begin -- Spider_Triangle