[SOLVED] COM1002 Lab 8

30.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

Task: Given at most 100 pa/ent names and their blood cell types (BCT), please provide the BCTs of the queried pa/ents.

Detailed SpecificaRons:

  • Assume that each pa/ent has only one record in the given list.
  • Read the given informa/on (i.e. pa/ent names and their BCTs) and load them to the memory,

i.e. using two different arrays. BCTs occupy at most 4 characters.

  • Pa/ent names may be queried from the standard input using a mix of capital and small leIers. Assume a match if the names match case insensi/vely.
  • Assume that each pa/ent name occupies at most 15 characters.
  • Output pa/ent names will be printed using all small leIers.
  • If the query item name is not in the given list, your program should print 0+ to the screen.
  • The list of pa/ent names and their BCTs are separated from the query names with the word: start
  • The query items are terminated with the word: end

Input format: [S] stands for a Space character

<paRent1_name>[S]< BCT1>

<paRent2_name>[S]< BCT2>

.. <paRentN_name>[S]< BCTN>

start

< paRentX_name> < paRentY_name>

< paRentZ_name>

.end

Output Forma_:

< paRentX_name>[S]< BCTX>

< paRentY_name>[S]< BCTY> 

< paRentZ_name>[S]0+                                                               // ! does not exist!

Hints:

  1. You can include <string.h> file and use related string func/ons if you need them.
  2. You can use [100][15] two dimensional character array to store the pa/ent names.
  3. You can use [100][5] two dimensional char array to store BCTs.
  4. When you load pa/ent names to the names character array, you should load the corresponding prices to the second (BCT) array with the same row index.

TesRng:

We provided you a sample I/O file pair. Test your programs with these files while developing your program. Moreover, create your own test files according to the specifica/ons to test more.

As usual, use input redirec+on mechanism of your opera/ng system to test your programs. For example, if your executable is called as Lab8, redirect the input.txt file to standard input using < operator and redirect your outputs to a file using > operator such as:

> ./Lab8<input.txt>output.txt

This kind of execu/on enables your programs to read inputs from a file without wri/ng any file related func/ons (e.g. fopen(), fscanf() etc.). In other words, the getchar() or scanf() func/ons in your code reads data from the redirected files instead of the std. input in this way (e.g. keyboard).

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.