Skip to main content

Posts

GPA Calculator using C++

SOURCE CODE: private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) { String^ pgrd1=(textBox1->Text); String^ pgrd2=(textBox2->Text); String^ pgrd3=(textBox3->Text); String^ pgrd4=(textBox4->Text); String^ pgrd5=(textBox5->Text); float GPA1,GPA2,GPA3,GPA4,GPA5; float GPA=0; if (pgrd1==""||pgrd2==""||pgrd3==""||pgrd4==""||pgrd5=="") { MessageBox::Show("Fields cannot be empty!"); } else { //***************************************1st subject***************************************************// if (pgrd1=="A+"||pgrd1=="A") { GPA1=4.0; } else if (pgrd1=="A-") { GPA1=3.7; } else if (pgrd1=="B+") { GPA1=3.3; } else if (pgrd1=="B") { GPA1=3.0; } else if (pgrd1==...

Object Oriented Programming - C++

Basic Console program using Visual Studio A program to input Student numbers and Student names and to display them at the end. "student.h" Header file class student { private: int stdNo; char stdName[20]; public: void setStdNo(int pNo); void setStdName(char pName[]); void printDetails(); }; "student.cpp" file (where methods are defined) #include "student.h" #include <cstring> #include <iostream> using namespace std; void student::setStdNo(int pNo) { stdNo=pNo; } void student::setStdName(char pName[]) { strcpy(stdName,pName); } void student::printDetails() { cout<<"Student ID is "<< stdNo<<endl; cout<<"Student Name is "<<stdName<<endl; } The main program #include "stdafx.h" #include "student.h" #include <iostream> using namespace std; int _tmain...