a ruby program problem
****************************************************************************
compute.rb
# Note I have changed the name of the function "print" to "prints" because I have used
# ruby's print function inside prints function.
class Histogram
@lowScore # lowest possible Score in scores
@hiScore # highest possible score in scores
@bucketSize # size of each bucket
@count # count of each bucket
@Count # number of scores
@Average # average of scores
@StdDev # standard deviation of scores
def initialize(lowScore=0,hiScore=100,bucketSize=10) # initializer function
@lowScore = lowScore
@hiScore = hiScore
@bucketSize = bucketSize
@count = Array.new((hiScore-lowScore)/bucketSize){0}
@Count = 0
end
def addScores(file) # add Score function
total = 0
File.open("scores.txt").each do |score|
addScore(score.to_i) # count of each bucket
@Count += 1 # count of the number of scores
total += score.to_i # sum of scores
end
@Average = total.to_f/@Count # average of score
tmp = 0
File.open("scores.txt").each do |score|
tmp += ((score.to_i-@Average)**2/@Count.to_f)
end
@StdDev = tmp**0.5 # standard deviation of score
end
def addScore(score) # fnction to increament the count of each bucket
i = (score-@lowScore)/@bucketSize
@count[i] += 1
end
def prints # function to print
max = @count.max
puts "Count = %s, Average = %s, StdDev = %s"%[@Count,@Average.round(2),@StdDev.round(2)]
while max>0
for s in @count
if s>=max
print "%3s%1s"%["*"," "]
else
print "%4s"%[" "]
end
end
puts ""
max = max -1
end
i = @lowScore
while i<@hiScore
print "%3s%1s"%[i,"."]
i = i+@bucketSize
end
print @hiScore
end
end
h = Histogram.new
h.addScores("scores.txt")
h.prints
a ruby program problem **************************************************************************** Ruby These short language exercises are intended to help you to...
CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...
What to submit: your answers to exercises 2. Write a Java program to perform the following tasks: The program should ask the user for the name of an input file and the name of an output file. It should then open the input file as a text file (if the input file does not exist it should throw an exception) and read the contents line by line. It should also open the output file as a text file and write...
please use the c language
Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...
Implement a Java program using simple console input & output and logical control structures such that the program prompts the user to enter 5 integer scores between 0 to 100 as inputs and does the following tasks For each input score, the program determines whether the corresponding score maps to a pass or a fail. If the input score is greater than or equal to 60, then it should print “Pass”, otherwise, it should print “Fail”. After the 5 integer...
Write python code on computer, No handwritten
code
You will implement a program which asks the user to enter scores of different courses in different semesters. The program should read the input and output some simple statistics 1. An example input string by the user is given below. Fal12016-coursel:82, course2:80,course3:85;Spring2018- course4:82;Fall2018-course5:85, course6:50, course7:78 Info from different semesters are separated by a ";", courses in each semester are separated by a,and score and corresponding course is separated by a, information of...
Java programming help My program wont run. could someone tell me why. everything seems correct to me... giving me the error: Exception in thread "main" java.lang.NumberFormatException: For input string: "Stud" at java.base/java.lang.NumberFormatException.forInputString(Unknown Source) at java.base/java.lang.Integer.parseInt(Unknown Source) at java.base/java.lang.Integer.parseInt(Unknown Source) at Util.readFile(Util.java:35) at Driver.main(Driver.java:8) _________________________________________________________________________________________________________________________ Program Prompt: Write a program to perform statistical analysis of scores for a class of students.The class may have up to 40 students.There are five quizzes during the term. Each student is identified by a four-digit...
Use your knowledge of algorithm development to create a program using RAPTOR to solve the problem below. Input a list of student names (in to array student[]) and testing scores stored in parallel arrays. Each student have 3 testing scores ranging from 0 to 100 (store into parallel array score1[], score2[], score3[]). Output average score for each student and print out what is his final grade. If average score <60, got F grade. If 60<=average score<70, got D grade. If...
ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...
Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions: 1. First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....
This is a java homework for my java class. Write a program to perform statistical analysis of scores for a class of students.The class may have up to 40 students.There are five quizzes during the term. Each student is identified by a four-digit student ID number. The program is to print the student scores and calculate and print the statistics for each quiz. The output is in the same order as the input; no sorting is needed. The input is...