Comparison between C++ console and graphic programming Zhengyu Lu Dimitar Pilev Department of Computer Science Department of Informatics Jilin University University of Chemical Technology and Metallurgy Jilin Province, China Sofia, Bulgaria
[email protected] while the rest of them are unknown and then we Abstract: Nowadays, the new students of
can create an application to calculate the
Computer Science learn programming starting
unknown ones. Now we are going to show a
with C or C++ in the black-white console. At first,
paper work in which we can create such a
they may feel very proud of themselves by
application. In this C++ program, there are
calculating or print the result on the Screen. As
several requirements that we need to follow and
time goes by, they may feel tired of the black-white
formulas to use accordingly. Here are some
box and prefer something new. Then the problem
details from the project.
comes, they should learn the basic C++ code by
In this paper work, we are going to deal with a
heart or just skip it to the graphic programming
matrix with 6 rows and 12 columns which stand
Which sometimes seems more interesting than
for 6 students and 12 degrees of subjects from 1
black-white console programming. And after the
to 5. 0 represents the ones we do not know. For
Graphic programming like MFC, CLR
example, the score of the first subject of the first
programming, we can even release the program
student is 1, however the score of the second
and make it a small software that can be set up in
subject is unknown. Then we are going to create
their own laptop. It is really more interesting. So
one application that can solve such a problem.
we will look at one example that we build the program through console and released-version
103005005040
graphic programming to see the difference and
005400400213
disadvantages and advantages of them.
240120304350 024050040020
C++; Console programming; Graphic KeywordsKeywords-C++;
004342000025
programming; Comparison;
1. Introduction of a program
103030020040
Encountering such a project, students learning
In our daily life, sometimes we are required to predict some unknown elements from what we have already known. For instance, some scores of a number of students’ subjects are known,
C++
may
choose
different
programming tools. In this essay, we based on Microsoft Visual Studio 2010 to solve it using console and windows programming. In the end, we compare the advantages and disadvantages of them.
2. Console Programming We are going to create a menu with four choices for the user to choose. They ” are “ Exit ”, “ About the Application ”,” ”. In Create a File File”” and “ Download a File File” the “ Exit Exit””, the user will kill the
In the function of menu() menu(), we set a loop and it
application. In “ About the Application ”,
will not stop until the user input “1” to choose
we will provide the user with the chief
”. “ Exit Exit”
information of the application. And in ”, “ Create a File File”” and “ Download a File File”
void menu(){
the user can create or download a file from
bool check=true;
the disk.
while(check){ welcome();
Now the next is to create different
...
functions to fulfill the requirements of the
}
four buttons.
”, we can print the In the choice of “ About us us” general information of the application easily.And ”, the if the user choose “ 3. Load a file file” application will provide the user with several choices first and read the file from disk after the user make a choice. After printing the information read from disk, it is time to predict the unknown ones now. Predictions can be calculated with the following formulas.
As we have shown, the application named
“
Recommender Recommender””
have
four
branches and each of them are made up of different functions. We will combine the running status and functions together to show how the application works.
Here is the first running step of the application.
where: •
Ru is the average of the ratings given by a user u (i.e., the average of the numbers Rui such that Rui !=0).
•
Iuv is the set of items that both u and v
have rated, i.e., the set of indexes i such that •
char * str=new char[u*i];
Rui!=0 and Rvi!=0.
wuv is the Pearson correlation of the
Secondly, write the original file into disk.
users u and v. Note that wuv is not
if(write.fail()){
defined and cannot be computed if Iuv
coutLocation =
}
System::Drawing::Point(31, 26); this->label4->Name = L"label4";
Next in the clear button button, we set the value of
this->label4->Size = System::Drawing::Size(95,
every element to blank. Here is the original code
12);
of how it works.
this->label4->TabIndex = 11; this->label4->Text = L"number of users";
for(int
Through these properties, we can control the
i=0;idataGridView1->RowCount;i++){
position, size, name and so on of the label.
for(int j=1;jdataGridView1->ColumnCount;j++)
In the choice list, we also provide two choices
{
for user and then download the elements from file to the form. Here is the code for choice list.
dataGridView1->Rows[i]->Cells[j]->Value ="";
// Set every element in the table into
blank if(curItem=="text.1"){
}
read.open("D:\\Project\\test1.txt"); //do not
}
forget to use "using namespace std;" Next in the predict button button, the same like
} else{
in console programming, we use various if(curItem=="text.2"){ read.open("D:\\Project\\test2.txt");
is more, we provide the function of reminding
}
the users of errors which may happen because of
else{
too many unknown numbers. read.open("D:\\Project\\test3.txt");
} } In the create button button, the application can create a table form for user according to his or her mind. Here is the example of creating columns in the form. for(int i=0; idataGridView1->RowCount; i++){
functions to predict the unknown numbers. What
// Create the first column,
if(iRows[i]->Cells[0]->Value =System::Convert::ToString(i+1); } else{ dataGridView1->Rows[i]->Cells[0]->Value
Last but not least, we can release this application which ca be set up and used in more computers.
Another thing, when we are using console programming, we can print the numbers no matter known or unknown directly in the screen, but for graphic programming it is different. We need to convert the numbers from float type to 4. Comparison between console programming and graphic programming. Differences
char type, so that they can be printed in the form, which may be a little complicated when compared with console programming. for(int i=0;iCells[j+1]->Value); }
created by graphic programming, which is more convenient. And also, with so many buttons and labels, it is more vivid to control the application created by graphic programming.
form with elements by himself or herself, which sometime is hard to control the rows and columns. In this example, we prefer to output the new elements with asterisk, which works better programming.
programming
than
} Next one, when we provide the functions to create and update files in console programming, which is more multi-functional. For user, he or
Secondly, the programmer has to create a
in graphic
//To get the
in
console
she can store the files in disk and check it in the future. But for many factors, we do not provide in graphic programming.
Console Programming Another one, about the size of form that we can use to store the numbers. In console
In console programming, programmer has to
programming, we can not change the size of the
create the form by himself which takes a longer
window so that we can only show a limited
time than graphic programming.
number of elements to users. While in graphic programming, it is very different and we can
Moreover, when programmer is creating the
input much more elements in the table. But here,
table, there are many factors to consider, such as
we only provide 20 rows and columns as an
how many digits the number has and how many
example. And also in graphic programming,
lines and columns the form needs, which is hard
users can change or correct the numbers they
to print accurately.
have inputted whenever they want before predict, which dose not work so well in console
The advantage is console program is smaller
programming.
than graphic program which takes more codes.
Last but not least, about the choice list. In console programming, we can only provide few
Graphic Programming
choices for users because of the limited size of window. While in graphic programming, the user
In graphic programming, the programmer can
have as many choices as they can, which
design the form by himself and what is more, visual studio 2010 can create these different buttons, labels and choice lists automatically, Which is very convenient for programmer.
benefits from the choice list that does not appear in console programming. Similarities
Obviously, the application created by graphic Both programs have two the same functions
programming is more vivid and has a better
” and which are responsible for “ Predict Predict”
interaction with the users. Also it is much easier
“ Create Create””.
to use the application with clicking mouse to
And also these two functions use the same way
control it.
to predict and share similar formulas to complete the calculations.
The disadvantage is with better appearance, the application needs more codes than console
Another one, we use the same three files to test
programming and as a result it takes more space
the accuracy of two applications. And of course,
to install in your computer.
the predicting results are the same. Both of them can be set up in users’ computer
For C++ beginners
with setup project created in the solution. Though graphic programming has better appearance and interaction with users, but we 5. Conclusion
Suggest that beginner users of c++ should acquire the basic programming skills and
Advantages and Disadvantages
knowledge first. After a long time practice of console programming, it will be easier and better
for them to learn to use graphic programming.
AUTHORS PROFILE
1. Zhengyu Lu
---
Junior student of Computer
Science and Technology in Jilin University, China. From Sep. 30, 2014 to Mar 19, 2015 studied in Chemical Technology and Metallurgy, Sofia, Bulgaria as an Erasmus student. During
this
time,
learned
and
cooperated with Dr. Pilev of Informatics Department in UCTM.
2. Dimitar Pilev
--- Doctor of Informatics in Chemical
Technology and Metallurgy in Sofia. Taught and guided Zhengyu Lu in C++ program work.