Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with an assignment coded in Ruby. Apologizes for posting a large assig

ID: 3890945 • Letter: N

Question

Need help with an assignment coded in Ruby. Apologizes for posting a large assignment but I am having trouble getting started trying to store user responses in Hashes and Arrays.

In a loop, the program will prompt the user (which is you) for a series of values which you will store in a Hash. As you start a new record, add the employee ID as a Fixnum to the Hash to act as the key. The value stored will be an Array.   By the end of the series of prompts, the program will have added the full record to a Hash. It will then ask if you want to enter another user record. If you answer "yes" or "Y" the program continues to prompt for the next record. If you enter anything other than "yes" or "Y" it will move to the next phase, which is to print a summary of all user records created in this run of the program. Your responses to the prompts are shown in bold 12-point Courier font.

The following is a sample run of the program with 3 records entered. When you test, create different numbers of records to be sure that it works correctly for 1 to n records.   You can assume the user always creates at least one user record.   You do not have to validate the data, and you can use one-character values as you test.

$ ./create_user_records.rb

Enter the user's employee id: 589

Enter the user's first name: John

Enter the user's last name: Smith

Enter the user's department number: 42

Enter the user's supervisor (full name): Hank Jones

Enter the user's Linux account ID: smithj1

Enter the user's temporary password: H0lyM0$es

Would you like to create another record (type yes or Y to continue): Y

Enter the user's employee id: 472

Enter the user's first name: Jane

Enter the user's last name: Doe

Enter the user's department number: 54

Enter the user's supervisor (full name): Art Tatum

Enter the user's Linux account ID: doej1

Enter the user's temporary password: $ecrEtW0rd

Would you like to create another record (type yes or Y to continue): Y

Enter the user's employee id: 467

Enter the user's first name: John

Enter the user's last name: Doe

Enter the user's department number: 42

Enter the user's supervisor (full name): Hank Jones

Enter the user's Linux account ID: doej2

Enter the user's temporary password: 0bfu$c8tion

Would you like to create another record (type yes or Y to continue): N

Summary

=============================

3 records created:

Name: John Smith

Employee Id: 589

Department: 42

Supervisor: Hank Jones

Username: smithj1

Password: H0lyM0$es

Name: Jane Doe

Employee Id: 472

Department: 54

Supervisor: Art Tatum

Username: doej1

Password: $ecrEtW0rd

Name: John Doe

Employee Id: 467

Department: 42

Supervisor: Hank Jones

Username: doej2

Password: 0bfu$c8tion

Grading Rubric (Requirements)

The full set of records must be stored as a Hash in which the key is the employee ID and the value is an Array. (10 points)

Other than the employee ID, all other fields are to be stored in an Array of Strings under the key mentioned above. (10 points)

Force the response to be on the same line as the prompt, as shown above, with two white spaces between the prompt's ending colon (:) and the user response. (10 points)

Provide a simple report with the general format and header as shown above (the word Summary and a line of = signs.) (10 points)

Do not hard-code the number of records entered. Use the size of the Array of Arrays to derive the number. (10 points)

Generate the report based on the natural order in which the records were entered using an iterator method on the Hash. (10 points)

Use String interpolation when generating the summary report. (10 points)

For all variables, any constants, etc., use descriptive names and observe Ruby conventions for variable naming, such as snake_case vs. camelCase. (10 points)

Provide meaningful comments at the block level. Zero comments, comments on every line, or extraneous trivial comments will result in a point deduction up to the full value allotted. (10 points)

Follow all code submission instructions below to the letter. Any departure from the instructions will result in at least a 5-point deduction. (10 points)

Explanation / Answer

#!/usr/bin/ruby

puts "Enter the user's employee id:"
employee_id = gets.to_i

puts "Enter the user's first name:"
first_name = gets.chomp

puts "Enter the user's last name:"
last_name = gets.chomp

puts "Enter the user's department number:"
dep_number = gets.chomp

puts "Enter the user's supervisor (full name):"
sup_name = gets.chomp

puts "Enter the user's Linux account ID:"
linux_id = gets.chomp

puts "Enter the user's temporary password:"
temp_pass = gets.chomp

puts "Would you like to create another record? (Type yes or Y to continue):"
continue_prog = gets.chomp


user_info = Hash.new
user_info = {
"employee_id" => employee_id,
"first_name" => first_name,
"last_name" => last_name,
"dep_number" => dep_number,
"sup_name" => sup_name,
"linux_id" => linux_id,
"temp_pass" => temp_pass
}

user_info.each do |key,value|
if value.respond_to? (:capitalize)
    puts "Your #{key.to_s} is #{value.capitalize}"
else
    puts "Your #{key.to_s} is #{value}"
end
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote