GP Calculator :-
- #include "stdafx.h" // heador file for MS visual Studio
- #include <iostream> // heador file. Some compiler used <iostream.h>
- #include <conio.h> // heador file
- #include <string> // heador file
- using namespace std;
- float round(float num)
- {
- int num1 = int(num * 100);
- return float(num1 / 100.0);
- }
- int main()
- {
- string user_name ;
- char* name[6] = {"Islamiat" , "Comunication skills" , "Discreate Mathematics" , "Calculus" , "Computer programming" , "Accounting" }; // You can change subject name.
- float GP [6] = {0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0};
- int marks ;
- int crunt_subject = 0;
- float gp = 0.0;
- float sum_qp = 0 ;
- float sgp;
- cout << "\n\t\t\t Mian Muhammad Huzaifah \n"<< "\t\t\t BS-IT 2nd (2012-2016)\n" << " \t\t The Islamia University Of Bahawalpur\n\n\n";
- cout << "Please enter your name : ";
- getline(cin, user_name); // you can use cin.getline(user_name , '\n')
- for (int i = 1 ; i <= 6 ; i++)
- {
- cout << "Please enter your marks in subject of " << name [crunt_subject] << " : ";
- cin >> marks ;
- {
- if (marks < 50)
- gp = 0.0 ;
- if (marks >= 50)
- {
- gp = 1.0;
- for (int j = 51 ; j <= marks; j++)
- gp = float(gp + 0.1);
- }
- if (marks > 70)
- {
- gp = 3.0;
- for (int k = 71 ; k <= marks ; k++ )
- gp = gp + 0.05;
- }
- if (marks > 80)
- {
- gp = 3.5;
- for (int n = 81 ; n <= marks ; n++ )
- gp = gp + 0.1;
- }
- if (marks > 85)
- gp = 4.0;
- if (marks > 100)
- cout << "Maximum marks of " << name[crunt_subject] << " is 100 . your enterd marks is out of range.";
- }
- GP[crunt_subject] = gp ;
- crunt_subject = crunt_subject + 1;
- }
- cout << endl << "********************************************************************************" << endl << "\t\t\t\t" << user_name << endl << endl << "********************************************************************************" ;
- crunt_subject = 0;
- for (int l = 1 ; l <= 6 ; l++)
- {
- cout << "Your GP in subject of " << name[crunt_subject] << " : " << GP[crunt_subject] << endl ;
- crunt_subject = crunt_subject + 1;
- }
- crunt_subject = 1;
- for (int m = 1 ; m < 6 ; m++)
- {
- float qp = GP[crunt_subject] * 3;
- sum_qp = sum_qp + qp ;
- crunt_subject = crunt_subject + 1 ;
- }
- sum_qp = sum_qp + GP[1];
- sgp = sum_qp / 16 ;
- cout << "Your SGP of 2nd smester is : " << round(sgp);
- _getch(); // Some compiler use getch();
- return 0;
- }
0 comments:
Post a Comment