Devlopment Some great tutorials regarding devloping a software. Some tutorials on C++,Java and Visual basic. This section also includes Web Development.


Reply
 
LinkBack Thread Tools
Old 11-07-08, 03:41 PM   #1
Hitterman Chopper Challenge Champion
TOTM Winner Feb
 
Hitterman's Avatar
 
Nick Name: Hitty
Join Date: April 2008
About Me: I like to play all the Sports.
Location: India
Posts: 1,533
tSCash: 362968
Hitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to behold
Default A basic percentage calculator

You may have to calculate percentage of your subjects in schools. However you can do that in copy but here is a simple tutorial on Making Percentage calculator in c++. This calculator is for 5 Subjects.

Code:
# include <iostream.h>
#  include <conio.h>

void main()
{
clrscr();
float a,b,c,d,e,f;
cout<<"Marks in English"<<endl;
cin>>a;
cout<<"Marks in Maths"<<endl;
cin>>b;
cout<<"Marks in Physics"<<endl;
cin>>c;
cout<<"Marks in Chemistry"<<endl;
cin>>d;
cout<<"Marks in Computers"<<endl;
cin>>e;

clrscr();
cout<<"Total of Marks "<<a+b+c+d+e<<endl;
cout<<"Total Percentage "<<(a+b+c+d+e)/5<<" % "<<endl;
getch();
}
cout: This command lets you to print text on the screen when you run the Application.
cin:Allows you to add dynamic values in your program.
float: A vaiable only used if your program has decimal values.
More coming soon
Using the techniques from this you can try more things like Biodata form.

__________________
CricketGaming.net .
Hitterman is offline   Reply With Quote
Old 11-07-08, 09:12 PM   #2
ramzz
Novice
 
ramzz's Avatar
 
Nick Name: Rameez
Join Date: June 2008
Location: Mississauga, Canada
Posts: 104
tSCash: 156
ramzz is on a distinguished road
Default

Good tutorial there Hitty!
__________________
ramzz is offline   Reply With Quote
Old 11-07-08, 11:15 PM   #3
EliteX
Novice
 
Join Date: June 2008
Location: Dreamland
Posts: 67
tSCash: 738
EliteX is on a distinguished road
Default

Can we add more subjects hitty?
__________________
EliteX is offline   Reply With Quote
Old 12-07-08, 11:12 PM   #4
halogen19
Banned
 
Join Date: May 2008
Posts: 14
tSCash: 350
halogen19 is on a distinguished road
Default

I didn't know a programmer could be this stupid. To calculate percentage you'll have to do (a+b+c+d+e) * 100 / 5! a+b+c+d+e / 5 is just the average, not the percentage! You don't even know the basic formulas?

Why do you have to load stdio and iostream both? stdio is only for C and not C++!
halogen19 is offline   Reply With Quote
Old 13-07-08, 06:51 PM   #5
Hitterman Chopper Challenge Champion
TOTM Winner Feb
 
Hitterman's Avatar
 
Nick Name: Hitty
Join Date: April 2008
About Me: I like to play all the Sports.
Location: India
Posts: 1,533
tSCash: 362968
Hitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to behold
Default

Even the most stupid programmer can easily get that when you take out percentage o ffive subjects 100 each then dividing by 5 or /500 * 100 is Same. I have just simplified it rather than writing the full formula and about stdio its not required here but if you wanted to add advanced commands for alligning etc it is useful.
__________________
CricketGaming.net .
Hitterman is offline   Reply With Quote
Old 13-07-08, 08:02 PM   #6
Abhinav
Newbie
 
Join Date: April 2008
Posts: 19
tSCash: 686
Abhinav is on a distinguished road
Default

Originally Posted by Hitterman View Post
Even the most stupid programmer can easily get that when you take out percentage o ffive subjects 100 each then dividing by 5 or /500 * 100 is Same. I have just simplified it rather than writing the full formula and about stdio its not required here but if you wanted to add advanced commands for alligning etc it is useful.
No, its not. stdio.h is the header file used for C programs. You have written this program in C++ so there is no need for stdio.h

Other than that the program is nice for beginners. But its not a tutorial since it doesn't explain how it works. The purpose of a tutorial should be to enable others to learn rather than encourage them to copy-paste.

Last edited by Abhinav; 13-07-08 at 08:04 PM.
Abhinav is offline   Reply With Quote
Old 13-07-08, 08:15 PM   #7
Hitterman Chopper Challenge Champion
TOTM Winner Feb
 
Hitterman's Avatar
 
Nick Name: Hitty
Join Date: April 2008
About Me: I like to play all the Sports.
Location: India
Posts: 1,533
tSCash: 362968
Hitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to behold
Default

Okay i'll remove stdio.h

Quote:
Other than that the program is nice for beginners. But its not a tutorial since it doesn't explain how it works. The purpose of a tutorial should be to enable others to learn rather than encourage them to copy-paste.
I agree with you, I just have written what i knew about C++ as i am also not very advanced in c++.
Thanks

-
__________________
CricketGaming.net .
Hitterman is offline   Reply With Quote
Old 06-01-09, 07:45 PM   #8
Shreyas
Novice
 
Join Date: April 2008
Location: India
Posts: 42
tSCash: 1020
Shreyas will become famous soon enough
Default

Here is an improvement over it:

PHP Code:
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    
int buffer;
    
float percent;
    
    
int totMarks;
    
int totMaxMarks;
    
int subjects;
    
totMarks 0;
    
totMaxMarks 0;
    
    
cout << "Enter number of subjects: ";
    
cin >> subjects;
    
subjects subjects;
    
cout << "\n\n";
    
    
    
int i;
    for(
1;<= subjectsi++)
    {
          
cout << "Enter marks for Subject " << << ": ";
          
cin >> buffer;
          
totMarks totMarks buffer;
          
cout << "Enter maximum marks for Subject " << <<": ";
          
cin >> buffer;
          
totMaxMarks totMaxMarks buffer;
          
cout << "\n\n";
    }
    
    
percent totMarks 100 totMaxMarks;
    
cout << "Your Percentage: " << percent << "\n\n\n";
    
    
main();
    
    return 
0;

Shreyas is offline   Reply With Quote
Old 21-01-09, 06:26 PM   #9
c0d1f1ed
Newbie
 
Join Date: January 2009
Posts: 10
tSCash: 1338
c0d1f1ed is on a distinguished road
Default

Beware that integer division rounds down. If you want to round to the nearest integer use the following:

percent = (totMarks * 100 + totMaxMarks / 2) / totMaxMarks;

It can only gain you one percentage point half of the time but it could be the difference between being grounded or not.
c0d1f1ed is offline   Reply With Quote
Old 21-01-09, 07:13 PM   #10
Hitterman Chopper Challenge Champion
TOTM Winner Feb
 
Hitterman's Avatar
 
Nick Name: Hitty
Join Date: April 2008
About Me: I like to play all the Sports.
Location: India
Posts: 1,533
tSCash: 362968
Hitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to beholdHitterman is a splendid one to behold
Default

Quote:
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
int buffer;
float percent;

int totMarks;
int totMaxMarks;
int subjects;
totMarks = 0;
totMaxMarks = 0;

cout << "Enter number of subjects: ";
cin >> subjects;
subjects = subjects;
cout << "\n\n";


int i;
for(i = 1;i <= subjects; i++)
{
cout << "Enter marks for Subject " << i << ": ";
cin >> buffer;
totMarks = totMarks + buffer;
cout << "Enter maximum marks for Subject " << i <<": ";
cin >> buffer;
totMaxMarks = totMaxMarks + buffer;
cout << "\n\n";
}

percent = totMarks * 100 / totMaxMarks;
cout << "Your Percentage: " << percent << "\n\n\n";

main();

return 0;
}
Return type and looping really improve the program but I think it is really hardfor the newbies to understand it. Looping needs some more conceps to be cleared . Thanks for the code.

Quote:
cout << "\n\n";
I think cout<<"\n; will also work nicely.
__________________
CricketGaming.net .
Hitterman is offline   Reply With Quote
Reply

Bookmarks

Tags
c++



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Calculator using Adobe Flash CS3 Oj_RuLeS Animation Tutorials 10 31-03-09 12:21 AM




All times are GMT +5.5. The time now is 10:41 AM.


Network: Tutorialistic.net | CricketGaming.net | Down The Wicket | CricketGaming.org | AshesGaming | Wrestle Gaming

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright © 2008 - 10, Tutorialistic.net