The names and student numbers of students are save in a text file called stnumbers.txt. Example of the content of the text file:   Peterson 20570856 Johnson 12345678 Suku 87654321 Westley 12345678 Venter 87654321 Mokoena 79012400 Makubela 29813360 Botha 30489059 Bradley 30350069 Manana 30530679 Shabalala 28863496 Smith 87873909 Nilsson 30989698 Makwela 30256607 Govender 30048117 Ntumba 30598303 Ramsamy 29952239 Skosana 29982995 Jameson 30228484 Xulu 29092248 Wasserman 27469352 Bester 28615425 Babane 27154033 Maboya 29897890 Mahlangu 30031338 Majavu 30165970 Myene 30954177 Motaung 30907276 Ramaroka 30804507 Radebe 30007674 Sekake 30017416 Zwane 30038227 Shuro 30238072 Viljoen 28881389 Sithole 45688555 Write a function called displayData() to receive the array and number of elements as parameters and display the names and student numbers of the students with a heading and neatly spaced.   Write a function, isValid(), which receives a number as parameter and determines whether the number is a valid student number or not. Use the following validity test to determine the validity of a student number: Student number: 20570856 sum = (2*8)+(0*7)+(5*6)+(7*5)+(0*4)+(8*3)+(5*2)+(6*1) result = sum%11 If the result equals 0, the number is a valid student number; if the result is not equal to 0, the number is an invalid student number. The function MUST use a loop to analyse the number by looking at each individual digit in the number. The function returns the Boolean value true (valid) or the Boolean value false (invalid) to the calling statement. Hint: Repeatedly use integer division (/) with 10 and the remainder after integer division (%) with 10 to isolate the individual digits of the number.   Write a function, writeToFiles(), which receives the array of Student structs and the number of elements in the array. If the student number is valid, the name and student number must be written to an output file, validNumbers.txt. If the student number is invalid, the name and student number must be written to an output file, invalidNumbers.txt. Display the number of valid and the number of invalid number. The function returns no value to the calling statement.   The above functions (readFile() and writeToFile()) must now be implemented in the main function (main()) as follows: 1. Declare a Student struct with a name field (string or array of char) and a stNumber field (integer). 2. Create an array of type Student struct and make provision for a maximum of 100 elements. 3. Call the readFile() function to read the contents of the text file “numbers.txt” to the array and return the number of elements read to the array. 4. Call the writeToFile() function to write the names and valid students numbers and names and invalid student numbers to two separate text files.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The names and student numbers of students are save in a text file called stnumbers.txt. Example of the content of the text file:

 

Peterson

20570856

Johnson

12345678

Suku

87654321

Westley

12345678

Venter

87654321

Mokoena

79012400

Makubela

29813360

Botha

30489059

Bradley

30350069

Manana

30530679

Shabalala

28863496

Smith

87873909

Nilsson

30989698

Makwela

30256607

Govender

30048117

Ntumba

30598303

Ramsamy

29952239

Skosana

29982995

Jameson

30228484

Xulu

29092248

Wasserman

27469352

Bester

28615425

Babane

27154033

Maboya

29897890

Mahlangu

30031338

Majavu

30165970

Myene

30954177

Motaung

30907276

Ramaroka

30804507

Radebe

30007674

Sekake

30017416

Zwane

30038227

Shuro

30238072

Viljoen

28881389

Sithole

45688555

Write a function called displayData() to receive the array and number of elements as parameters and display the names and student numbers of the students with a heading and neatly spaced.

 

Write a function, isValid(), which receives a number as parameter and determines whether the number is a valid student number or not. Use the following validity test to determine the validity of a student number: Student number: 20570856 sum = (2*8)+(0*7)+(5*6)+(7*5)+(0*4)+(8*3)+(5*2)+(6*1) result = sum%11 If the result equals 0, the number is a valid student number; if the result is not equal to 0, the number is an invalid student number. The function MUST use a loop to analyse the number by looking at each individual digit in the number. The function returns the Boolean value true (valid) or the Boolean value false (invalid) to the calling statement. Hint: Repeatedly use integer division (/) with 10 and the remainder after integer division (%) with 10 to isolate the individual digits of the number.

 

Write a function, writeToFiles(), which receives the array of Student structs and the number of elements in the array. If the student number is valid, the name and student number must be written to an output file, validNumbers.txt. If the student number is invalid, the name and student number must be written to an output file, invalidNumbers.txt. Display the number of valid and the number of invalid number. The function returns no value to the calling statement.

 

The above functions (readFile() and writeToFile()) must now be implemented in the main function (main()) as follows: 1. Declare a Student struct with a name field (string or array of char) and a stNumber field (integer). 2. Create an array of type Student struct and make provision for a maximum of 100 elements. 3. Call the readFile() function to read the contents of the text file “numbers.txt” to the array and return the number of elements read to the array. 4. Call the writeToFile() function to write the names and valid students numbers and names and invalid student numbers to two separate text files.

 

List of students
Peterson
Johnson
Suku
Westley
Venter
Mokoena
Makubela
Botha
Bradley
Manana
Shabalala
Smith
Nilsson
Makwela
Govender
20570856
12345678
87654321
12345678
87654321
79012400
29813360
30489059
30350069
30530679
28863496
87873909
30989698
30256607
30048117
Transcribed Image Text:List of students Peterson Johnson Suku Westley Venter Mokoena Makubela Botha Bradley Manana Shabalala Smith Nilsson Makwela Govender 20570856 12345678 87654321 12345678 87654321 79012400 29813360 30489059 30350069 30530679 28863496 87873909 30989698 30256607 30048117
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education