Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab3 Roll Call System For this problem, we hope all of you to learn how to implement linear congruential generator and read file in C++.

Lab3 Roll Call System

For this problem, we hope all of you to learn how to implement linear congruential generator and read file in C++.

We will provide you template class file, you have to complete class methods by yourself. What you need to do in lab3:

(1) Open the file that stores all students names from outside.

(2) Add all student names to a vector.

(3) Randomly pick some student names (by linear congruential generator) and add them to another vector.

(4) Calculate how many different alphabets (lowercase and uppercase are the same) are there from picked student names. We provide a file (lab3.cpp) and a test case (student.txt) for you.

Inside lab3.cpp: Class member: int a, c, m, seed fstream fin vector studentName, pickedStudentName Class methods: void OpenFile() : open the file void AddNames() : add names to studentName vector. int GenerateRandomNumber() : randomly generate the integer. void PickNames(): pick names from studentName vector. void PrintPickedStudentNames() print all picked names. void CaculateAlphabets(): calculate how many different alphabets are used in picked names.

Hint: (1)Linear Congruential Generator: A Linear Congruential Generator (LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. m: 0 < m, the modulus a: 0 < a < m, the multiplier c: 0 <= c < m, the increment X0: 0 <= X0, m, the seed (start value)

Your file should be put in the same directory of your c++ project. I/O Specification: Input file: (Please dont modify the file) First line: the number of students After adding all student names, you will see how many times you should do the test, and then you will see other numbers for (seed, a, c, m, pick_student_num) Output: You need to input the filename first, and then let your program run.

Ans: What kind of information do you need?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions