Programming using Unicomal - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Programming using Unicomal

Description:

CANADA. Please enter the currency ?DOLLARS. Please enter the exchange rate ?4.25. Please enter the date ?27.10.00. CANADA 27.10.00 ... – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 16
Provided by: For95
Category:

less

Transcript and Presenter's Notes

Title: Programming using Unicomal


1
Programming using Unicomal
2
Car rental - Topic 6
This program displays a table that converts
pounds to another currency. Please enter the
country ?CANADA Please enter the
currency ?DOLLARS Please enter the exchange
rate ?4.25 Please enter the date ?27.10.00
CANADA 27.10.00 POUNDS DOLLARS 1 4.25 2 8.5 .
.. . .. 19 80.75 20 85
3
Inputs
This program displays a table that converts
pounds to another currency. Please enter the
country ?CANADA Please enter the
currency ?DOLLARS Please enter the exchange
rate ?4.25 Please enter the date ?27.10.00

country
currency
exchange_rate
todays_date
4
Output
CANADA 27.10.00 POUNDS DOLLARS 1 4.25 2 8.5 .
.. . .. 19 80.75 20 85
2
3
20
5
Design - Top Level
  • 1. Clear the screen
  • 2. Leave a blank line
  • 3. Tell the user what the program does
  • 4. Prompt for and input the country, currency,
    exchange rate and date
  • 5. Clear the screen
  • 6. Output the headings - country, date, POUNDS
    and currency
  • 7. Use a loop to output each row of the table

6
Refinement for step 4
This program displays a table that converts
pounds to another currency. Please enter the
country ?CANADA Please enter the
currency ?DOLLARS Please enter the exchange
rate ?4.25 Please enter the date ?27.10.00
  • 1. Prompt for input country
  • 2. Prompt for input currency
  • 3. Prompt for input exchange_rate
  • 4. Prompt for input todays_date

7
Refinement for step 6
CANADA 27.10.00 POUNDS DOLLARS 1 4.25 2 8.5 .
.. . .. 19 80.75 20 85
  • 1. Output the country and todays_date
  • 2. Leave a blank line
  • 3. Output POUNDS and currency

8
Refinement for step 7
CANADA 27.10.00 POUNDS DOLLARS 1 4.25 2 8.5 .
.. . .. 19 80.75 20 85
  • 1. Loop for each value of pounds from 1 to 20
  • 2. Output pounds in 1st column
    pounds exchange_rate in 2nd column
  • 3. End loop

9
The main program
100 // Currency conversion program, Topic 6 Task
4 110 // 120 // . 130
PAGE 140 PRINT 150 inform_user 160
input_values 170 PAGE 180 output_headings 190
output_table 200 END 210 // 220 //
1. Clear the screen 2. Leave a blank line 3.
Tell the user what the program does 4. Prompt
for and input the country, currency, exchange
rate and date 5. Clear the screen 6. Output the
headings - country, date, POUNDS and currency 7.
Use a loop to output each row of the table
10
Inform_user
1000 PROC inform_user 1010 // This procedure
tells the user what the program does 1020 PRINT
This program displays a table that
converts 1030 PRINT pounds to another
currency. 1040 PRINT 1050 ENDPROC
inform_user 1060 // 1070 //
11
Input_values
1. Prompt for input country 2. Prompt for
input currency 3. Prompt for input
exchange_rate 4. Prompt for input todays_date
  • 2000 PROC input_values
  • 2010// This procedure gets the user to input 4
    variables
  • 2020 PRINT Please enter the country
  • 2030 INPUT country
  • 2040 PRINT Please enter the currency
  • 2050 INPUT currency
  • 2060 PRINT Please enter the exchange rate
  • 2070 INPUT exchange_rate
  • 2080 PRINT Please enter the date
  • 2090 INPUT todays_date
  • 2100 ENDPROC input_values

12
Output_headings
Output the country and todays_date 2. Leave a
blank line 3. Output POUNDS and currency
  • 3000 PROC output_headings
  • 3010 // This procedure displays the headings in
    the correct place
  • 3020 PRINT TAB(5)country TAB(30) todays_date
  • 3030 PRINT
  • 3040 PRINT TAB(5) POUNDS TAB(30) currency
  • 3050 ENDPROC output_headings

13
Output_table
1. Loop for each value of pounds from 1 to 20 2.
Output pounds in 1st column pounds
exchange_rate in 2nd column 3. End loop
  • 4000 PROC output_table
  • 4010 // This procedure .
  • 4020 FOR pounds 1 TO 20 DO
  • 4030 PRINT TAB(5),poundsTAB(30),
    poundsexchange_rate
  • 4040 NEXT pounds
  • 4050 ENDPROC output_table

14
Lets use 2 decimal placesin 2nd column
CANADA 27.10.00 POUNDS DOLLARS 1 4.25 2 8.5 .
.. . .. 19 80.75 20 85
  • 4030 PRINT TAB(5),poundsTAB(30),
    poundsexchange_rate
  • Is replaced by -
  • 4030 PRINT TAB(5),poundsTAB(30)
  • 4035 PRINT USING .poundsexchange_rate

15
Whats next?
  • You can now do the General assessment on Page 39.
Write a Comment
User Comments (0)
About PowerShow.com