GP Calculator




GP Calculator :-


  1. #include "stdafx.h" // heador file for MS visual  Studio 
  2. #include <iostream>  // heador file. Some compiler used <iostream.h>
  3. #include <conio.h>   // heador file 
  4. #include <string>   // heador file  

  5. using namespace std;

  6. float round(float num)
  7. {
  8. int num1 = int(num * 100);
  9. return float(num1 / 100.0);
  10. }

  11. int main()
  12. {
  13. string user_name ;
  14. char* name[6] = {"Islamiat" , "Comunication skills" , "Discreate Mathematics" , "Calculus" , "Computer programming" , "Accounting" };    // You can change subject name.
  15. float GP [6] = {0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0};
  16. int marks ;
  17. int crunt_subject = 0;
  18. float gp = 0.0;
  19. float sum_qp = 0 ;
  20. float sgp;
  21. 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";
  22. cout << "Please enter your name : ";
  23. getline(cin, user_name);  // you can use cin.getline(user_name , '\n')
  24. for (int i = 1 ; i <= 6 ; i++)
  25. {
  26. cout << "Please enter your marks in subject of " << name [crunt_subject] << " : ";
  27. cin >> marks ;
  28. {
  29. if (marks < 50)
  30. gp = 0.0 ;
  31. if (marks >= 50)
  32. {
  33. gp = 1.0;
  34. for (int j = 51 ; j <= marks; j++)
  35. gp = float(gp + 0.1);
  36. }
  37. if (marks > 70)
  38. {
  39. gp = 3.0;
  40. for (int k = 71 ; k <= marks ; k++ )
  41. gp = gp + 0.05;
  42. }
  43. if (marks > 80)
  44. {
  45. gp = 3.5;
  46. for (int n = 81 ; n <= marks ; n++ )
  47. gp = gp + 0.1;
  48. }
  49. if (marks > 85)
  50. gp = 4.0;
  51. if (marks > 100)
  52. cout << "Maximum marks of " << name[crunt_subject] << " is 100 . your enterd marks is out of range.";
  53. }
  54. GP[crunt_subject] = gp ;
  55. crunt_subject = crunt_subject + 1;
  56. }
  57. cout << endl << "********************************************************************************" << endl << "\t\t\t\t" << user_name << endl << endl << "********************************************************************************" ;
  58. crunt_subject = 0;
  59. for (int l = 1 ; l <= 6 ; l++)
  60. {
  61. cout << "Your GP in subject of " << name[crunt_subject] << " : " << GP[crunt_subject] << endl ;
  62. crunt_subject = crunt_subject + 1;
  63. }

  64. crunt_subject = 1;
  65. for (int m = 1 ; m < 6 ; m++)
  66. {
  67. float qp = GP[crunt_subject] * 3;
  68. sum_qp = sum_qp + qp ;
  69. crunt_subject = crunt_subject + 1 ;
  70. }
  71. sum_qp = sum_qp + GP[1];
  72. sgp = sum_qp / 16 ;

  73. cout << "Your SGP of 2nd smester is : " <<  round(sgp);
  74. _getch();  // Some compiler use getch();
  75. return 0;
  76. }


Next PostNewer Post Previous PostOlder Post Home

0 comments:

Post a Comment