Use Rust to implement the following. 1. (20 points) Create a public struct called StudentGrades. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Use Rust to implement the following. 1. (20 points) Create a public struct called StudentGrades. The struct contains a name and a vector of grades. The StudentGrades struct has at least two methods (associated func- tions): average and grade. The average method returns the average score for that student. The grade method returns the student's letter grade based on the scale below. The Stu- dentGrades should not lose any information when calling either average or grade. Letter Grade A B () D F 90-100% 80-89% roger, 100.0, 80.0, 80 pete, 70, 75.5,73 70-79% 60-69% 0-59% 2. (20 points) Create a public struct called CourseGrades. The struct has a type-associated function from_file(file_path:String). The argument to the method is a path to a file. The method reads the file. For each line in the file, it creates a StudentGrades object. Each line of the file is in the format: name, grade1, grade2, ..., gradeN That is, each line starts with a name, followed by a comma, which is followed by optional spaces, which are followed by a numerical score. Each score represents a grade event, that is, an assignment or exam. Grades are separated by a comma followed by optional spaces. Here is a sample file: The struct has at least two methods: (associated functions): average and student. With the input N an integer, the average method returns the average score of all students on the N'th grade event. The first grade event is indexed by 1, not 0. average returns an Option, as the input N could be out of range. student has one parameter: a string which is a student's name. It returns an Option. If the name is found in the course, the StudentGrades is returned. Neither method should be destructive. You are not to use a CSV crate or libraries. Use Rust to implement the following. 1. (20 points) Create a public struct called StudentGrades. The struct contains a name and a vector of grades. The StudentGrades struct has at least two methods (associated func- tions): average and grade. The average method returns the average score for that student. The grade method returns the student's letter grade based on the scale below. The Stu- dentGrades should not lose any information when calling either average or grade. Letter Grade A B () D F 90-100% 80-89% roger, 100.0, 80.0, 80 pete, 70, 75.5,73 70-79% 60-69% 0-59% 2. (20 points) Create a public struct called CourseGrades. The struct has a type-associated function from_file(file_path:String). The argument to the method is a path to a file. The method reads the file. For each line in the file, it creates a StudentGrades object. Each line of the file is in the format: name, grade1, grade2, ..., gradeN That is, each line starts with a name, followed by a comma, which is followed by optional spaces, which are followed by a numerical score. Each score represents a grade event, that is, an assignment or exam. Grades are separated by a comma followed by optional spaces. Here is a sample file: The struct has at least two methods: (associated functions): average and student. With the input N an integer, the average method returns the average score of all students on the N'th grade event. The first grade event is indexed by 1, not 0. average returns an Option, as the input N could be out of range. student has one parameter: a string which is a student's name. It returns an Option. If the name is found in the course, the StudentGrades is returned. Neither method should be destructive. You are not to use a CSV crate or libraries.
Expert Answer:
Answer rating: 100% (QA)
Yes here is an example of how the requirements are implemented in Rust This ... View the full answer
Posted Date:
Students also viewed these mathematics questions
-
The medication industry has at least two types of firms. The first type is biotechnology companies that focus their efforts on research and development (R&D) of new drugs. The second type is...
-
Let DOUBLE-SAT = {| has at least two satisfying assignments}. Show that DOUBLE SAT is NP-complete.
-
(a) Find a minimum-row PLA table to implement the following equations: x (A, B, C, D) = m(0, 1, 4, 5, 6, 7, 8, 9, 11, 12, 14, 15) y (A, B, C, D) = m(0, 1, 4, 5, 8, 10, 11, 12, 14, 15) z (A, B, C, D)...
-
A 1.000 m by 1.500 m by 2.000 m cube of a continuous solid is deformed (dashed line in the figure) into a shape by the movement of point E to E'. Considering small deformations, the displacement...
-
Suppose that the standard- setting body in a country has decided to adopt IASB standards for publicly traded companies. Explain this decision from the perspective of the public interest theory of...
-
As cars travel, oil and gasoline leaks onto the road surface. If a light rain falls, what does this do to the control of the car? Does a heavy rain make any difference? where B is the bulk modulus, V...
-
What topics should a ConOps, at a minimum, include?
-
Baliga Co. produces and sells high-quality audio equipment. To finance its operations, Baliga Co. issued $18,000,000 of five-year, 8% bonds with interest payable semiannually at a market (effective)...
-
Stock X has a standard deviation of return of 10%. Stock Y has a standard deviation of return of 20%. The correlation coefficient between stocks is 0.5. If you invest 60% of the funds in stock Xand...
-
The Apex Television Company has to decide on the number of 65 and 55 sets to be produced at one of its factories. Market research indicates that at most 280 of the 65 sets and 70 of the 55 sets can...
-
1. Regarding bias and variance, which of the followingstatements are true? (Here high and low are relative tothe ideal model.) Models which underfit have a high variance. Models which underfit have a...
-
Given the following information, calculate each organization's times-interest-earned ratio and debt ratio. Which organization is in the stronger position? Seven Kingdoms Corp Snow Corp. Net Income...
-
5. Unilever's cost of goods sold for 2014 is $36 million. How much inventory (in $) does the company hold if it has a one-month supply of inventory on average
-
6. Why is a color-blind ideology problematic? Why can't we ignore "color" and create a raceless society? 7. How does Whiteness function as a location of structural advantage? What is your...
-
1. In each of the following cases, draw a graph showing an increase or decrease in equilibrium interest rates. a. Suppose the demand for loanable funds remains unchanged. Will the equilibrium...
-
In 1999, GLSEN identified that little was known about the school experiences of lesbian, gay, bisexual, transgender, and queer (LGBTQ+) youth and that LGBTQ+ youth were nearly absent from national...
-
The 0 . 3 5 0 . 3 5 lbf ball is shot from the spring device shown. The spring has a stiffness k = 1 2 = 1 2 lbf / / in . . The plate reduces the spring to 1 . 5 1 . 5 inches in length, when its...
-
Saccharin is an artificial sweetener that is used in diet beverages. In order for it to be metabolized by the body, it must pass into cells. Below are shown the two forms of saccharin. Saccharin has...
-
Applying the criterion for equilibrium, derive the Clausius-Clapeyron equation.
-
For the system methanol (1)-methyl acetate (2), the activity coefficients for components 1 and 2 are represented by where \[ \begin{aligned} \ln \gamma_{1} & =A x_{2}^{2} \quad \text { and } \quad...
-
The pure component vapour pressure of two organic liquids \(\mathrm{X}\) and \(\mathrm{Y}\) by Antoine equations are given by \[ \ln P_{1}^{\text {Sat }}=14.35-\frac{2942}{T+220} \] and \[...
Study smarter with the SolutionInn App