Designing and Writing a Program

Authors Avatar

Task – Designing and Writing a Program

Problem

Write a program to calculate the volume of a cuboid. The program should assign values for the length, height and breadth and the result should be displayed on the screen ten times.

1) INPUT, PROCESS, OUTPUT TABLE 

2) PROGRAM IN PSEUDO CODE

Level 1

  1. assign the values
  2. calculate the volume
  3. display the result

Level 2

  1. assign a value to the variable breadth
  2. assign a value to the variable height
  3. assign a value to the variable length
  4. assign a value to the variable volume
Join now!

2.1 volume = breadth*height*length

3.1 display the result

3) PROGRAM IN VISUAL BASIC

Sub Command1_Click()

  assign_values

  calculate_volume_of_cube

  display_result

End Sub

Sub assign_values()

  breadth_of_cube = InputBox("Key in the breadth_of_cube")

  height_of_cube = InputBox("Key in the height_of_cube")

  length_of_cube = InputBox("Key in the length_of_cube")

End Sub

Sub calculate_volume_of_cube()

  volume_of_cube = breadth_of_cube * height_of_cube * length_of_cube

End Sub

Sub display_result()

  Print volume_of_cube

  Print volume_of_cube

  Print volume_of_cube

  Print volume_of_cube

  Print volume_of_cube

  Print volume_of_cube

  Print volume_of_cube

  Print volume_of_cube

  Print volume_of_cube

  Print ...

This is a preview of the whole essay