Vai al contenuto

Challenge 2012-01

DiscussioneEasy Challenge 1

Write a program to write out the current date and time in this format (date format my vary if you are in US): 20:06:34 Saturday 31/12/2011

DiscussioneEasy Challenge 2

Write a program to place a randomly sized and positioned rectangle on the GraphicsWindow and then get the Turtle to draw round the rectangle’s perimeter.

DiscussioneFile and Text Challenge

  1. Write a program to read an entire text file into a SmallBasic variable.
    You need to create a sample text file (sample.txt) somewhere first.
  2. Write a program to write out the data in a variable to a text file.
  3. Combine the 2 programs above into one program with 2 subroutines, one each to read and write to a file.
    Add some user input to ask for the input and output file names (inside the subroutines) so that a file can be read in and then written out to a different file.
  4. Print out each character and its the Unicode value to the textwindow for each character in the text file.
    Hint look at Text.GetLength, Text.GetSubText and Text.GetCharacterCode.
    You need to check each character in a loop.
  5. Count the number of lines in the text file.
    Hint: the unicode (ascii) codes for a ‘line feed’ is 10 and a ‘carriage return’ is 13.
    These occur at the end of each line of text.
  6. Modify the program to remove the Unicode character output, but ask the user for some sub-text to change and replace to something else.
    Get the program to find all occurrences of the sub-text and replace it with the replacement text and write the modified file out.

Intermediate Challenge

A company manufactures two types of tiles.

Type A is a trapezium with bottom 15 cm, top 5 cm and height of 10 cm
Type B is a parallelogram with base 14 cm and height 8 cm

Determine the total cost of labor which is calculated by the square centimeters of tiles produced.

In January there were 2,500 tiles of type A at a cost of 0.20 per square centimeter and 3,500 tiles of type B at a cost of0.10 per square centimeter.

In February production of both tiles increases by 50% over January and maintained costs per unit.

Find the area of the trapezium and the parallelogram to calculate the area of each of the tiles.
Calculate the monthly cost of labor for the months of January and February for each type of tile.
Calculate the total monthly cost of labor for the months of January and February.

Advanced Challenge 1

Write a program to rotate a wireframe cube in 3D.

Advanced Challenge 2

Extend the Text and File Challenge to write a compression and decompression algorithm for this text file.
The compressed file must also store any information required for the decompression.

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.