QuestionQuestion

Complete the following code requirements in the Pascal language. Your final code must compile and run.
1. You must create a record for a car. A car has the following attributes: an id number (integer), a manufacturer (string), a model (string) and a registration code (string). In your code create a Pascal record for the car using appropriate field names for each attribute.
Also include the following type definition at the top of your program: type Cars = Array of Car;
2. Write a function called ReadCar(): Car; that reads from the terminal values for each of the fields in a Car record and returns the completed record.
3. Write a procedure called WriteCar(c: Car); that takes a car record and writes each of the fields to the terminal with a description for the field as well as the field value.
4. Write a function called ReadAllCars(count: Integer): Cars; that calls your ReadCar() function count times and stores each car in Cars.
5. Write a procedure called WriteAllCars(carArray: Cars); that calls your WriteCar() procedure for each car in carArray.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

type Car = RECORD
       id:integer;
       manufacturer:string;
       model:string;
       registration_code:string;
    END;

type Cars = Array of Car;

// 2. Write a function called ReadCar(): Car; that reads from the terminal values for each of the
// fields in a Car record and returns the completed record.

function ReadCar(): Car;
var
    ca:Car;
begin
    write('Enter id: ');
    read(ca.id);
    readln(ca.manufacturer);
    write('Enter manufacturer: ');
    readln(ca.manufacturer);
    write('Enter model: ');
    readln(ca.model);
    write('Enter registration code: ');
    readln(ca.registration_code);   
    ReadCar := ca;
end;...

By purchasing this solution you'll be able to access the following files:
Solution.pas.

$30.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats