Cramster.com - Homework Solutions, Lecture Notes, Exams, and Free Online Homework Help
Sign Up Now! Login Customer Support Cramster Blog
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Problem Solved.
    Home    
    Homework Help    
   Answer Board   
    Resources (Beta)    
   
Member's Topic Headline:

Ruby programming!!! I need help, cant figure it out. I really need help... please.

Know the answer? Have a better solution? Share it.
Sign Up Now for FREE!
Join the thousands of students
getting ahead in their classes.
Member Testimonials

Question:

Advertisement:

Answer | Ask New Question | Customize Profile | Leaderboards | 
FAQ

Member's Avatar

Pupil
Karma Points: 60
Respect (63%):
Date Posted: 7/24/2008 6:50:48 PM  Status: Live
Ruby programming!!! I need help, cant figure it out. I really need help... please.
Course Textbook Chapter Problem
Operating Systems Learn to program N/A N/A
Question Details:

 

Program Specifications

The input for the program will be a set of id numbers for students at a university, who are applying for job as student workers with the school. The purpose of the program is to generate some statistics and totals about some characteristics of the applying students. (By the way, a realistic application would have the applicant records stored in a file, and have the program read from the file. Since we have not covered files in Ruby, we will read the id numbers from the console using gets.)

Id numbers will be 7 digits with the following format: the first 2 digits represent a code. The next digit represents the gender of the student, with 0 for males and 1 for females. The last 4 digits are the year of birth.

The program should prompt for and read and process id numbers, until a negative number or zero is input. To process an id number, first extract the code, the gender, and the birth year. (Do this using the % operator and integer division.) Subtract the birth year from 2008 to give an approximation of the student's age.

For each student number, output a line labeled like the following that lists the student's code, their gender (Male, Female, or Unknown) , and their age. For an id number of 4211983, the output should be this.

Code: 42 Gender: Female Age: 25

Keep track of the following totals and counts in the main loop in the program for the student numbers: 1) count the number of male applicants, 2) count the number of female applicants, 3) count the number of applicants of unknown gender, 4) count the number of applicants with ages between 18 and 24, and 5) total the ages.

.

When control exits the loop do any final necessary calculations and output a final report that is labeled similar to the following about the student applicants.

Total applicants: 8

Male applicants: 2

Female applicants: 5

Unknown gender: 1

Average age: 24.25

Age 18-24 applicants: 50

Program Implementation and Testing

Test your program completely. You may assume that id numbers input into the program are correct. You do not need to worry about the consequences of a user entering a number like 4502125. Although, remember the gender may be unknown (the third digit of the id may be a number other than 0 or 1

Bonus Point Alert! Earn +2 additional karma points for helping this monthly member.

Answers:

No one has answered this question yet.
Be the first to answer.  Earn up to 11 karma points. 
Redeem your points for Karma Points Rewards.


By reading or posting messages on these forums, you are agreeing to the Answer Board's Terms of Service and Conduct (TSC).


About Cramster | Terms of Use | Privacy Policy | Contact Us | Press Room | Site Map | Support | Anti-Cheating Policy

Cramster.com is not affiliated with any publisher. Book covers, title and author names appear for reference only.
Copyright © 2008 Cramster, Inc.