MC102

Computer Algorithms and Programming

Fourth List of Exercises

The exercises on this list cover classes until 10/04.
  1. Do a procedure that receives a string and returns it written backwards.
  2. Make a program that reads a string from the keyboard and says if it is a palíndrome. A string is a palíndrome when it can be read both backwards and forwards and has exactly the same sequence of characters. Ex .: ASA, SUBI IN THE BUS. Disregard spaces. Define a function called Palindrome that takes a string as a parameter and returns a boolean in your program. Tip: Use the function of exercise 1.
  3. Make a function that counts how many capital letters there are in a string received as a parameter.
  4. Make a function that counts how many lowercase letters there are in a string received as a parameter.
  5. Make a function that changes all uppercase letters to lowercase letters and lowercase letters to uppercase letters of a string received as a parameter.
  6. Make a function that receives 2 strings (A and B) and returns a third string (C) formed by the characters of A and B interspersed. Ex .: If A = 'Fourth' and B = 'Second', the answer must be 'QSueagrutnada'.
  7. Make a function that given the strings C and B from the previous exercise, return the string A.
  8. Make a function that receives as input three strings (A, B and C) and returns a fourth string formed by replacing all occurrences of string B with string C within string A. Ex .: If A = 'Open the door to enter to be able to rest calmly ', B =' to 'and C =' and try ', the answer should be:' Open the door and try to enter and try to rest calmly '.
  9. Make a procedure that takes two numbers as a parameter and order them.
  10. Make a procedure that receives 3 numbers as a parameter and order them. Use the previous procedure.
  11. Given the record:
    Type Person = Record
      Name: String [40];
    Address: String [40];
    Neighborhood: String [40];
    City: String [20];
    State: String [2];
    CEP: String [8];
    Age: Integer;
    Height: Real;
    Weight: Real;
    End;

  12. Do the following procedures / functions:
    • LePerson: (function) Reads all data from a person on the keyboard.
    • WritePeople: (procedure) Writes all the data of a person on the screen.
    • Older: (function) Receives two records as a parameter (A and B) and returns true if person A is older than person B.
    • Newest: (function) Receives two records as a parameter (A and B) and returns true if person A is younger than person B.
    • Exchange: (procedure) Receive two records as a parameter and change their value.
  13. Given the record:
    Type Student = Record
      Name: String [40];
    RA: String [6];
    Fouls: Integer;
    Proof: Array [1..3] Of Real;
    Laboratory: Array [1..15] Of Boolean;
    Media: Real;
    Exam: Real;
    Final Note: Real;
    Result: String [20];
    End;
    Do the following procedures / functions:
    • LeStudent: (function) Reads the name, RA, test scores, and laboratory deliveries (true for laboratory delivered and false otherwise).
    • Writing: (procedure) Writes all student data on the screen.
    • Calculate Average: (procedure) Calculates the student's final average according to the rules for this discipline and stores it in the Media field.
    • Review: (procedure) Reads a student's exam grade (only if the average is less than 5,0) and places it in the Exam field.
    • CalculateNoteFinal: (procedure) Calculates the student's final grade according to the rules for this discipline and stores it in the Final Grade field.
    • Calculate Result: (procedure) Checks the student's Final Grade field and also the number of absences and places one of the following values ​​in the Result field: 'Passed' if the student passes, 'Failed by grade' if the student fails by grade and 'Failed for absence 'if the student fails for absences.
    • Students: (procedure) It receives a vector with 100 students and an N number as parameters and prints the first N students of the vector (use the WriteStudent function to print).
    • Show Approved: (procedure) Receives a vector with 100 students and an N number as parameters and prints the approved students among the first N students in the vector.
    • Disapproved: (procedure) Receive a vector with 100 students and an N number as parameters and print the failed students among the first N students of the vector.
    Make a program that declares a vector of 100 students and shows a Menu to the user with an option for each of the functions / procedures above. Also include an option to end the program.
  14. How would you define a record to contain data for:
    • A new vehicle from a car dealership
    • An appliance from a store
    • A student's grades in a discipline
    • All student grades for a semester
    • All student grades during the course
    • All subjects in a course
    Perform functions / procedures to read and write each of the records you have defined.