What is Scilab ?
Scilab is free and open source software for numerical computation providing a powerful computing environment for engineering and scientific applications.
Scilab is released as open source under the CeCILL license (GPL compatible), and is available for download free of charge. Scilab is available under GNU/Linux, Mac OS X and Windows XP/Vista/7/8 (see system requirements).
What Will I Learn?
- Calculating Mean of Weekly Number of Solved Questions on Program
- Calculating Total of Monthly Number of Solved Questions on Program
- Calculating Total of Yearly Number of Solved Questions on Program
Requirements
- Scilab Development
- Scilab 'SciNotes'
- ' Scilab 6.0.0 Console '
- MacOs, Windows etc. Platforms
Difficulty
- Intermediate
Tutorial Contents
In this lesson we will create a program that will solve the weekly, monthly and yearly amount of questions needed for the students who will take the university entrance exam.
In our program you will be asked to enter which days and how many questions are solved. Our program will have a program feature that will help us figure out how many questions can be solved per week, month and year based on the number of questions entered per day.
Let's start from step 1 with a detailed description of each of our software codes used in our program.
STEP 1
First we will need to specify the button to be entered in order for the program to repeat. Our first code;
restart='Y';
The program will start to work again with the indicated ' Y ' button.
You will be asked for the number of questions solved daily.
STEP 2
In this step, the ' Y ' button specified in the previous step must be written on the ' while ' loop, and it must be written for repetition
of operations and codes executed under this loop. Our current code is;
while(restart=='Y');
With the loop we have defined, we can pass our next codes.
STEP 3
In this step, process is the initialization of the program and the display of the text on the screen. With the ' disp ' commands,
the display of the text while the program is running. Since we are already in the program, we would like to be able to enter a resultant title in the work process.
disp('Question Solving for University : ');
disp('=======================================');
After we write our headers, we write the code for the next step, data entry.
STEP 4
In this step, we will write down the number of solved questions per day that we want to input with the ' input ' code. Our code for writing the number of questions solved for Monday;
a=input('Number of Solved Questions on Monday ? : ');
Here, ' a ' is a name that is used only for specifying the value of the program. Let's do the same while writing the number of questions solved on other days. I share everything in turn;
b=input('Number of Solved Questions on Tuesday ? : ');
c=input('Number of Solved Questions on Wednesday ? : ');
d=input('Number of Solved Questions on Thursday ? : ');
e=input('Number of Solved Questions on Friday ? : ');
f=input('Number of Solved Questions on Saturday ? : ');
g=input('Number of Solved Questions on Sunday ? : ');
The writing of the number of questions solved daily was completed.
STEP 5
At this step, the user will be asked to wait for the sequences to be processed. To do this we will use the ' disp ' code we use again;
disp('Please Wait.');
Now do the sequence specification process;
y=[a b c d e f g];
If you want to know how to create arrays, you can look at the polynomial tutorial I created on my profile.
Link of Lesson;
STEP 6
In this step we will create a menu for the user and indicate that the desired result will be displayed on the screen with the number specified in the menu. Firstly, to distinguish this menu from the previous entries;
disp('---------------------------------------');
after that, creating menu;
disp('(1) Number of Mean Solved Questions per Week');
disp('(2) Number of Mean Solved Questions per Mounth');
disp('(3) Number of Mean Solved Questions per Year');
Create a space for the result that will be output after you specify the menu.
disp(' ');
STEP 7
At this step, our program will ask the user what operation to perform on the menu. The user can see the desired number from ' 1 - 2 - 3 ' which he has entered. Our code is required;
query=input('Which Result Do You Want to See [1-3]? ');
In here, ' query ' represents the number in the program.
STEP 8
In this step, we came to the most important part of the program. The codes we use will be ' If - Elseif - Else - End '. The reason we use this pattern is that the user will be asked to reflect
on the screen the result that the user will get with the number. The reason for doing this is that the number entered in the program is introduced to the program by specifying the
condition. The program will reflect the desired result on this screen. You can check out the previous lesson on my profile to learn more about this topic;
Specify our first condition code;
if (query==1) then
hes=mean(y);
By clicking on the ' 1 ' key of the user to be described here, we want to average the ' y ' sequence, the sequence we introduced earlier. So here it is; ' If the user clicks on the ' 1 ' key, get
averages of daily solving questions! ' command.
STEP 9
In this step, the user will be able to click on the ' 2 ' key and the result will be displayed on the screen. Our required code is;
elseif(query==2)
hes=sum(y)*4;
The ' Elseif ' command is used to specify the conditions after the ' If ' command. The ' sum ' command is used to get the sum of the specified ' y ' array elements. The user should collect
the number of solved questionnaires written for weekly endpoint additioning and multiply by 4.
STEP 10
In this step, we will specify what to do when there are no conditions specified with ' Else ' command. If the user does not click on the ' 1 - 2 ' key and clicks the ' 3 ' key;
else(query==3)
hes=sum(y)*52;
The elements of the ' y ' array will multiply by 52 to calculate the sum yearly.
In this step, finishing with;
end
code.
STEP 11
In this step we will write the title to show the desired result on the screen. We will use again ' disp ' code;
disp(' ');
disp([hes],'Desired Result = ');
disp(' ');
STEP 12
As we mentioned at the beginning, we started with a loop the user must click on the ' Y ' key to repeat the program. We will end up in this step the keystroke that the user of the loop will input. Required codes;
restart=input('Do You Want to Do Another Process [Y-N]? :','s');
end
With the ' input ' code, the user clicks the ' Y ' key if he wants to restart the program. Finishing software of the program, we write
' end ' command at the end.
Now I share with you the screenshot of the codes in the ' SciNotes ' window in the Scilab software program;
Finally, I share with you all the code I need to create the program:
restart='Y';
while(restart=='Y');
disp('Question Solving for University : ');
disp('=======================================');
a=input('Number of Solved Questions on Monday ? : ');
b=input('Number of Solved Questions on Tuesday ? : ');
c=input('Number of Solved Questions on Wednesday ? : ');
d=input('Number of Solved Questions on Thursday ? : ');
e=input('Number of Solved Questions on Friday ? : ');
f=input('Number of Solved Questions on Saturday ? : ');
g=input('Number of Solved Questions on Sunday ? : ');
disp('Please Wait.');
y=[a b c d e f g];
disp('---------------------------------------');
disp('(1) Number of Mean Solved Questions per Week');
disp('(2) Number of Mean Solved Questions per Mounth');
disp('(3) Number of Mean Solved Questions per Year');
disp(' ');
query=input('Which Result Do You Want to See [1-3]? ');
if (query==1) then
hes=mean(y);
elseif(query==2)
hes=sum(y)*4;
else(query==3)
hes=sum(y)*52;
end
disp(' ');
disp([hes],'Desired Result = ');
disp(' ');
restart=input('Do You Want to Do Another Process [Y-N]? :','s');
end
STEP 13
We will now start the program that we have done in this step. By entering the number of questions solved according to the days, we
will see the weekly, monthly and yearly results on the screen. Let's start the run and share the first image on the screen;
Now let's start writing down the number of questions that are solved daily;
For Monday ' 45 '
For Tuesday ' 50 '
For Wednesday ' 60 '
For Thursday ' 75 '
For Friday ' 50 '
For Saturday ' 83 '
For Sunday ' 110 '
Now let's make a choice from our menu and click on the ' 1 ' ;
The result of weekly: ' 67.571429 '
Now, start the program again and press the ' 2 ' key after writing the same data and see the resut of the month;
The results of mounthly ' 1892 '
Now let's click on the ' 3 ' key and see the end result;
The results of yearly: ' 24596 '
In this lesson, we made our weekly, monthly and yearly results program with the daily question solutions of the students prepared for the university.
Your questions and opinions are valuable to me. You can reach me through the comment section.
Curriculum
- GITHUB LINK
- LESSON 15
- LESSON 14
- LESSON 13
- LESSON 12
- LESSON 11
- LESSON 10
- LESSON 9
- LESSON 8
- LESSON 7
- LESSON 6
- LESSON 5
- LESSON 4
- LESSON 3
- LESSON 2
- LESSON 1
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it does not follow the Utopian Rules.
Related Rule:
Suggestions:
You can contact us on Discord.
[utopian-moderator]