Hi, I want to make the final output to 4 decimal places. But it kept showing only 1. I tried a lot but doesn't work. Please help me

4 views (last 30 days)
Ass_1 = input("Lab Assignment #1:");
Ass_2 = input("Lab Assignment #2:");
Ass_3 = input("Lab Assignment #3:");;
%Quizzes
quiz_1 = input("Quiz 1:");
quiz_2 = input("Quiz 2:");
quiz_3 = input("Quiz 3:");
final_exam = input("Final Exam:");
disp([('Your calculated final mark for is '),num2str(totalass*60/100+totalquiz*10/100+final_exam*30/100)]);

Accepted Answer

Chunru
Chunru on 8 Jan 2022
Ass_1 = 60;
Ass_2 = 75;
Ass_3 = 80;
totalass = (Ass_1 +Ass_2 + Ass_3)/3;
%Quizzes
quiz_1 = 76;
quiz_2 = 90;
quiz_3 = 54;
totalquiz = (quiz_1 + quiz_2 + quiz_3)/3;
final_exam = 73;
finalmark = totalass*60/100+totalquiz*10/100+final_exam*30/100;
fprintf('Your calculated final mark for is %.1f\n', finalmark);
Your calculated final mark for is 72.2

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!