Question

Coding language is Matlab Given a mock set of grades and names of students: studentNames =...

Coding language is Matlab

Given a mock set of grades and names of students:

studentNames = ["Amy", "Flynn", "Barbara", "George", "Jonathan", "Isaac", "Cindy",

"Hank", "Elaine", "Debbie"];

Test1 = [79, 71, 98, 68, 65, 97, 72, 68, 68, 82];

Test2 = [61, 94, 98, 66, 91, 90, 76, 86, 67, 88];

Final = [68, 84, 85, 90, 91, 85, 88, 80, 51, 72];

I need the following questions answered and coded out:

a) “

If Test 1 and 2 were worth 30% each of the grade, and the final was worth 40%what is the average grade for each student.

b) Which students made above average on both test 1 and test 2

c) Which students made above average on the final, but below average on both tests.

d) Which student had the best average overall?

e) Who was the lowest scoring student on each exam

On each question I want the student name, and the output to a file names “students.txt” in a

complete sentence

. Use %s in your print statements to print a string similar to the example:

fprintf(fileID, “student name is %s”, studentName);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

% Matlab script to calculate some statistics on the grades of students in
% Test1 , Test2 and Final and output the results to file
% define the vectors of names and scores
studentNames = ["Amy", "Flynn", "Barbara", "George", "Jonathan", "Isaac", "Cindy", "Hank", "Elaine", "Debbie"];
Test1 = [79, 71, 98, 68, 65, 97, 72, 68, 68, 82];
Test2 = [61, 94, 98, 66, 91, 90, 76, 86, 67, 88];
Final = [68, 84, 85, 90, 91, 85, 88, 80, 51, 72];

% open the output file
fid= fopen('students.txt','w');

%a) If Test 1 and 2 were worth 30% each of the grade, and the final was worth 40%what is the average grade for each student.
% calculate the weighted grade for each student
weighted_grade = Test1.*0.3 + Test2.*0.3 + Final.*0.4;
% output the result to file
for i=1:length(studentNames)
fprintf(fid,'Average grade for %s is %.2f\n',studentNames(i),weighted_grade(i));
end

%b) Which students made above average on both test 1 and test 2
% find returns the index of students who made above average on both test 1 and test 2
students_above_avg_both_tests = find(Test1 > mean(Test1) & Test2 > mean(Test2));
% output the results to file
for i=1:length(students_above_avg_both_tests)
fprintf(fid,'%s made above average on both test1 and test2\n',studentNames(students_above_avg_both_tests(i)));
end

%c) Which students made above average on the final, but below average on both tests.
% find returns index of students who made above average on the final, but below average on both tests.
students_above_avg_final = find(Final > mean(Final) & Test1 < mean(Test1) & Test2 < mean(Test2));
% output the results to file
for i=1:length(students_above_avg_final)
fprintf(fid,'%s made above average on Final both below average on both tests\n',studentNames(students_above_avg_final(i)));
end

%d) Which student had the best average overall?
% calculate the overall average grade for all students
overall_average_grade = (Test1+Test2+Final)./3;
% max returns the maximum overall average grade from overall_average_grade
% vector and the index of students with that grade
[best_average_overall, idx] = max(overall_average_grade);
% output the results to file
for i=1:length(idx)
fprintf(fid,'%s has the best average overall with average grade %.2f\n',studentNames(idx(i)),best_average_overall);
end

%e) Who was the lowest scoring student on each exam
% minimum returns the minimum score for Test1 , Test2 and Final and index
% of students with the minimum score respectively
[min_test1,idx1] = min(Test1);
[min_test2,idx2] = min(Test2);
[min_final,idxfinal] = min(Final);
% output the results to file
for i=1:length(idx1)
fprintf(fid,'%s has the best minimum score of %.2f in Test1\n',studentNames(idx1(i)),min_test1);
end

for i=1:length(idx2)
fprintf(fid,'%s has the best minimum score of %.2f in Test2\n',studentNames(idx2(i)),min_test2);
end

for i=1:length(idxfinal)
fprintf(fid,'%s has the best minimum score of %.2f in Final\n',studentNames(idxfinal(i)),min_final);
end
fclose(fid); % close the file
%end of script

Output:

Add a comment
Know the answer?
Add Answer to:
Coding language is Matlab Given a mock set of grades and names of students: studentNames =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MATLAB Assignment help studentNames = ["Amy", "Flynn", "Barbara", "George", "Jonathan", "Isaac", "Cindy", "Hank", "Elaine", "Debbie"]; Test1...

    MATLAB Assignment help studentNames = ["Amy", "Flynn", "Barbara", "George", "Jonathan", "Isaac", "Cindy", "Hank", "Elaine", "Debbie"]; Test1 = [79, 71, 98, 68, 65, 97, 72, 68, 68, 82]; Test2 = [61, 94, 98, 66, 91, 90, 76, 86, 67, 88]; Final = [68, 84, 85, 90, 91, 85, 88, 80, 51, 72]; Modify this to answer the following question: Who was the lowest scoring student on each exam? Each question must be formatted like so: the student name, and the output...

  • A student recieves test scores of 62, 83 and 91. The students final exam score is...

    A student recieves test scores of 62, 83 and 91. The students final exam score is 88 and homework score is 76. Each test is worth 20% of the final grade, the final exam is worth 25% of the final grade and homework grade is worth 15% of the final grade. Using weighted average, what is the students numerical grade for the course.

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • a) Create a Table called Students b) Develop a Form with the following fields FName, LName,...

    a) Create a Table called Students b) Develop a Form with the following fields FName, LName, Test1, Test2, Test3,State c)Using the Form fill the Table with the following data FName LName Test Test 2 Test 3 State Bob Smith 79 81 86 NY Thorpe 82 Griffey 100 Colon Jim 64 91 Conn Ohio Ken 95 92 85 Bartolo 88 93 Ohio Cal Ken Keltner 91 84 87 Lou Staub 76 89 42 Mich PROBLEM: Find and print the LName of...

  • C++ program that reads students' names followed by their test scores (5 scores) from the given...

    C++ program that reads students' names followed by their test scores (5 scores) from the given input file, students.txt. The program should output to a file, output.txt, each student's first name, last name, followed by the test scores and the relevant grade. All data should be separated by a single space. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, an array of testScores of type int...

  • IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the...

    IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then outputs the average grade for each student. It also outputs the highest grade a student earned in each test, and the average of all grades in each test. Your output should look like this: Mary's average grade was 78.8% Harry's average grade was 67.7% etc... : In test 1 the highest grade was 93% and...

  • C++ Language A continuation of your grading software will be made you do not need your...

    C++ Language A continuation of your grading software will be made you do not need your other code for this assignment). In this one you will intake a students first name and last name from a file called "students.txt". Next, there is a file called grades.txt that contains the grades in a course. There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt" there are two students first and last names. In "grades.txt" the...

  • Write a program that uses the keys(), values(), and/or items() dict methods to find statistics about...

    Write a program that uses the keys(), values(), and/or items() dict methods to find statistics about the student grades dictionary. Find the following: Print the name and grade percentage of the student with the highest total of points. Also print the grade as per the below grading scale 90 to 100         A 80 to 89           B 70 to 79           C 60 to 69           D Below 60         F Find the average score of each assignment. Use the following data:...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT