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...
-
Flanders, Inc., has a $700,000, 8 percent bond issue that was issued a number of years ago at face value. There are now 10 years left on the bond issue, and the market interest rate is 16 percent....
-
The traction drive uses the capstan drive system shown in Figure CDP2.1. Neglect the effect of the motor inductance and determine a state variable model for the system. The parameters are given in...
-
Don Griffin worked as an accountant at a local accounting firm for five years after graduating from college. Recently, he opened his own accounting practice, which he operates as a corporation. The...
-
A scale is constructed using the 10-kg mass, the 2-kg pan P, and the pulley and cord arrangement. Cord BCA is 2 m long. If s = 0.75 m, determine the mass D in the pan. Neglect the size of thepulley....
-
Explore the utilization of advanced land-use planning frameworks, such as agent-based modeling and cellular automata, for simulating dynamic urban growth patterns and predicting the long-term effects...
-
The production manager at a factory manufacturing four types of light fittings (A, B, C and D) on an automated machine is fixing the schedule for the next week on this machine. HEIJUNKA SCHEDULING OF...
-
Who has this role of communicating the organizational changes of the company to its employees? What are the qualities they must possess in order to play this role? Is there a way, that you understand...
-
what ways does cultural globalization foster hybridity, homogenization, or resistance, as cultural products, practices, and identities circulate and interact on a global scale ?
-
How do transnational corporations, global financial institutions, and supranational organizations influence and govern global economic flows, governance structures, and policy agendas in the era of...
-
Crane Company's unit costs based on 100000 units are: Variable costs $60 Fixed costs 40 Crane's normal unit selling price is $165. A special order from Astra International, an Indonesian firm, has...
-
The 2022 accounting records of Oriole Company reveal these transactions and events. Payment of interest $10,100 Payment of salaries and wages 57,800 Cash sales 49.100 Depreciation expense 16,600...
-
what extent does neoliberal globalization reshape patterns of global production, trade, and investment, while exacerbating inequalities and restructuring power relations within and between nations ?
-
Consider a production function of Cobb-Douglas form: F(L,K)= LOK, for some a, (0, 1). (a) Plot the isoquant of F. (b) Derive that technical rate of substitution of F. Does Fexhibit diminishing...
-
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...
-
Find the z-scores that bound the middle 70% of the area under the standard normal curve.
-
Find the z-scores that bound the middle 80% of the area under the standard normal curve.
-
Find the z-scores that bound the middle 98% of the area under the standard normal curve.
Study smarter with the SolutionInn App