Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Secret Student Data ==================== type Student struct { Name string RollNo int } type SecretStudent struct { SecretCode string ChunkSize int Length int StudentDetail Student

Secret Student Data ====================

type Student struct { Name string RollNo int }

type SecretStudent struct { SecretCode string ChunkSize int Length int StudentDetail Student }

A teacher want to share details of students to school's management. All the data can be accessed using roll number, name and secret code. The teacher shares this information using go channels. But before writing to channel the teacher modifies secret code according to following rules- 1- You divide the SecretCode in equal size chunks 2- Re-arrange the chunks in reverse order 3- If length is such that it cannot be divided in equal size chunks then you pad the secret code using '0'. Eg: secret code length is 8 and chunk size is 5 so you add "00" in secret code which makes the length 10 and get each chunk of size 5

Write a program in which a go routine 'teacher' takes three SecretStudent objects. Modifies the secret code according to the rules. Convert the object to byte array(using json encoding) and write the byte array to A channel

Another go routine 'management' reads from the channel. Decode the byte array and display the recieved SecretStudent. After that fix the SecretCode and display it.

Here are 2 examples for secretCode modification

Examples1 =========== Input: SecretCode: abcdefghijkl ChunkSize: 4 Length: 12

Output: ijklefghabcd

Examples2 =========== Input: SecretCode: abcdefghijkl ChunkSize: 5 Length: 12

Output: kl000fghijabcde ========================================================================================

- BY using GOLANGUAGE.

- Please give me the exact solution

- Do not emplement any logic in main - Refactor the code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions