Thursday, July 26, 2018

Student Database Grading System in C++

In this article I would like to share with you a database system that I wrote in C++ and my back end is binary file in C++ that has a function to add,edit, view and delete the record of the student. It has also a function to compute the student grades. 

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Sample Program Output



Program Listing

student.cpp

// student.cpp
// Written By Mr. Jake R. Pomperada, BSCS, MAED-IT
// July 26, 2018  Thursday
// Bacolod City, Negros Occidental Philippines

#include <iostream>
#include <iomanip>
#include <cmath>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>

 using namespace std;


int main( )
{
FILE *fp, *ft ;
char another, choice ;
struct student
{
char stud_id_no[300];
char name[300];
char course[300];
char subject[300];
float prelim,midterm,endterm,final_grade;
} ;
struct student grade;
char student_id[300];
long int recsize;
    int flag=0;
fp = fopen ("GRADE_DB.DAT", "rb+" ) ;
if ( fp == NULL )
{
fp = fopen ( "GRADE_DB.DAT", "wb+" ) ;
if ( fp == NULL )
{
puts ( "Cannot open file" ) ;
exit(0) ;
}
}
recsize = sizeof ( grade ) ;
while ( 1 )
{
       system("CLS");
         setprecision(0);
        cout <<"\n";
cout << "\n============================================";
cout <<"\n";
cout <<"\n STUDENT GRADING DATABASE SYSTEM IN C++";
cout <<"\n";
cout << " Created By Mr. Jake R. Pomperada, MAED-IT";
cout <<"\n=============================================";
cout <<"\n\n";
cout << "1. INSERT STUDENT RECORD";
cout <<"\n";
cout << "2. BROWSE STUDENT RECORD";
cout <<"\n";
cout << "3. EDIT STUDENT RECORDS" ;
cout <<"\n";
cout  << "4. FIND STUDENT RECORDS";
cout <<"\n";
cout << "5. REMOVE STUDENT RECORDS";
cout <<"\n";
cout  << "6. QUIT PROGRAM" ;
cout <<"\n\n";
cout  <<"SELECT YOUR OPTION :=> ";
fflush (stdin) ;
choice = getche() ;
switch ( choice )
{
case '1' :
fseek ( fp, 0 , SEEK_END ) ;
another = 'Y' ;
while ( another == 'Y' )
{
system("cls");
cout <<"\n\n";
cout << "=== INSERT NEW STUDENT GRADE RECORD ===";
cout <<"\n\n";
cout <<"Enter Student ID Number : ";
                    cin >> grade.stud_id_no;
cout << "Enter Student Name: ";
fflush (stdin) ;
gets(grade.name);
cout <<"Enter Course : ";
fflush (stdin) ;
gets(grade.course);
                    cout <<"Enter Subject : ";
fflush (stdin) ;
gets(grade.subject);
cout <<"Enter Prelim Grade: ";
cin >> grade.prelim;
cout << "Enter Midtem Grade: ";
cin >> grade.midterm;
cout << "Enter Endterm Grade: ";
cin >> grade.endterm;
grade.final_grade = (grade.prelim * 0.30) + (grade.midterm * 0.30) + (grade.endterm * 0.40);
cout << "\n";
                    cout << "\n Student Final Grade : "  << round(grade.final_grade);
fwrite (&grade, recsize, 1, fp ) ;
cout << "\n\n";
cout  << "\nAdd New Student Record (Y/N) : " ;
fflush (stdin) ;
another = toupper(getche()) ;
}
break ;
case '2' :
        system("cls");
rewind ( fp );
cout << "\n\n";
                cout <<"=== VIEW STUDENT GRADE RECORD ===";
                cout <<"\n\n";
while ( fread ( &grade, recsize, 1, fp ) == 1 )
        {
       cout <<"\n";
       cout <<"\n  ID Number        : " <<grade.stud_id_no;
       cout <<"\n  Name             : " <<grade.name;
       cout <<"\n  Course           : " <<grade.course;
       cout <<"\n  Subject          : " << grade.subject;
       cout <<"\n  Prelim Grade     : " <<grade.prelim;
       cout <<"\n  Midterm Grade    : " <<grade.midterm;
       cout <<"\n  Endterm Grade    : " <<grade.endterm;
       cout <<"\n";
       grade.final_grade = (grade.prelim * 0.30) + (grade.midterm * 0.30) + (grade.endterm * 0.40);
       cout <<"\n Student Final Grade : " <<round(grade.final_grade);
  }
          cout <<"\n\n";
         system("pause");
break ;
case '3' :
another = 'Y' ;
while ( another == 'Y' )
{
system("cls");
          cout <<"=== EDIT STUDENT GRADE RECORD ===";
        cout <<"\n\n";
          cout <<"Enter Student ID Number : ";
                cin >> student_id;
    rewind ( fp ) ;
cout <<"\n";
while ( fread ( &grade, recsize, 1, fp ) == 1 )
{
if ( strcmp ( grade.stud_id_no, student_id) == 0 )
{
cout <<"Enter Student ID Number : ";
                            fflush (stdin) ;
                            gets(grade.stud_id_no);
cout <<"Enter Student Name : ";
fflush ( stdin ) ;
gets(grade.name);
        cout <<"Enter Course: ";
fflush ( stdin ) ;
gets(grade.course);
cout <<"Enter Subject : ";
fflush ( stdin ) ;
gets(grade.subject);
cout <<"Enter Prelim Grade : ";
cin >> grade.prelim;
cout <<"Enter Midtem Grade : ";
cin >> grade.midterm;
cout <<"Enter Endterm Grade: ";
cin >> grade.endterm;
cout <<"\n";
grade.final_grade = (grade.prelim * 0.20) + (grade.midterm * 0.30) + (grade.endterm * 0.50);
cout <<"\n Student Final Grade : " << round(grade.final_grade);
fseek ( fp, - recsize, SEEK_CUR ) ;
fwrite ( &grade, recsize, 1, fp ) ;
break ;
}
}
if (strcmp(grade.stud_id_no,student_id) != 0 )
                 {  
                   cout <<"\n\n";
                   cout <<"No Student Record in the Database.";
                   cout <<"\n";
                   system("pause");
                   break;
                   }
                 cout <<"\n\n";
     cout  <<"\nEdit Another Student Record (Y/N) : ";
fflush ( stdin ) ;
another = toupper(getche());
}
break ;
      case '4' :
   rewind ( fp ) ;
    another = 'Y' ;
while ( another == 'Y' )
{
system("cls");
        cout <<"=== Find Student Records ===";
        cout <<"\n\n";
     cout <<"Enter Student ID Number : ";
                 cin >>student_id;
cout <<"\n";
rewind ( fp ) ;
while ( fread ( &grade, recsize, 1, fp ) == 1 )
{
if ( strcmp (grade.stud_id_no,student_id) == 0 )
{
                    cout <<"\n";
cout <<"\n ID Number      : " <<grade.stud_id_no;
cout <<"\n Name           : " << grade.name;
cout <<"\n Course         :  " <<grade.course;
            cout <<"\n Subject        : " <<grade.subject;
                    cout <<"\n Prelim Grade   :  " <<grade.prelim;
                   cout <<"\n  Midterm Grade  :  " <<grade.midterm;
                   cout <<"\n  Endterm Grade  : " << grade.endterm;
                   cout <<"\n";
       grade.final_grade = (grade.prelim * 0.30) + (grade.midterm * 0.30) + (grade.endterm * 0.40);
       cout <<"\n Student Final Grade : " << round(grade.final_grade);
       cout <<"\n\n";
       system("pause");
       break;
}
}
      if (strcmp(grade.stud_id_no,student_id) != 0 )
          {
            cout <<"\n\n";
            cout <<"No Student Record found in the Database.";
            cout <<"\n";
            system("pause");
            break;
           }
                    cout  <<"\n\n";
cout  <<"\n Find Another Student Record (Y/N) : " ;
fflush ( stdin ) ;
another = toupper(getche());
}
break ;
case '5' :
another = 'Y' ;
while ( another == 'Y' )
{
system("cls");
                    cout <<"=== REMOVE STUDENT GRADE RECORD ===";
                    cout <<"\n\n";
cout <<"Enter Student ID Number : ";
                    cin >> student_id;
cout <<"\n";
ft = fopen ( "TEMP.DAT", "wb" ) ;
rewind ( fp ) ;
while ( fread ( &grade, recsize, 1, fp ) == 1 )
{
if ( strcmp (grade.stud_id_no, student_id) != 0 )
fwrite ( &grade, recsize, 1, ft ) ;
                 else
                flag=1;
                  }
fclose ( fp ) ;
fclose ( ft ) ;
remove ( "GRADE_DB.DAT" ) ;
rename ( "TEMP.DAT", "GRADE_DB.DAT" ) ;
    fp = fopen ( "GRADE_DB.DAT", "rb+" ) ;
       if(flag==1) {
         cout <<"\n\n";
         cout <<"Record Successfully Deleted From the Database.";
         cout <<"\n";
         system("pause");
         }
else if (flag!=1) {
             cout <<"\n\n";
             cout <<"Record Not Found in the Database.";
             cout <<"\n";
            system("pause");
             }
                    cout <<"\n\n";
cout << "Remove Another Student Record (Y/N) : " ;
fflush (stdin) ;
another = toupper(getche());
}
break ;
case '6' :
fclose ( fp ) ;
cout <<"\n\n";
cout <<"END OF PROGRAM";
cout <<"\n\n";
cout << "Thank You Very Much For Using This Software.";
cout <<"\n\n";
system("PAUSE");
exit(0);
}
}

}

Tuesday, July 24, 2018

Largest and Smallest Number Determiner in C++

In this article I would like to share the work of my student named Arjay Lucernas Vicente we ask permission to him if we can share his work in our website which he agrees to help also other programmers around the world. This program will ask the user to give three numbers and then the program will determine which of the three numbers given is the highest and smallest in terms of values using C++. I would like to thank Arjay for sharing his work to us.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

number.cpp


/* Arjay Lucernas Vicente */
/* July 23, 2018 */

#include <iostream>
#include <stdlib.h>

using namespace std;
int main()
{

 int a, b, c;
    int smallest, largest; 
    cout << "Please enter 3 numbers: " ;
    
    cout<<"ikauna nga numero ";
    cin>> a;
    cout<<"\n\n";
    cout<<"ikaduwa nga numero ";
    cin>> b;
    cout<<"\n\n";                                                                                 
    cout<<"ikatatlo numero ";
    cin>> c;
    cout<<"\n\n";  
    

    smallest = a;
    largest = a;

    if (b > largest) 
            largest = b;
    if (c > largest)
            largest = c;
    if (b < smallest)
            smallest = b;
    if (c < smallest)
            smallest = c;

    cout << "largest: " << largest;
    cout << "\n\n";
cout << "smallest: "<< smallest << endl;
cout <<"\n\n\n";
const int SIZE = 11;
    for (int i = 0; i<SIZE; i++)
    {
        std::cout << (((1 + (i * 2)) < SIZE) ? std::string((SIZE / 2 - (1 + (i * 2)) / 2), ' ') : std::string((SIZE / 2 - (SIZE * 2 - (1 + (i * 2))) / 2), ' ')) << (((1 + (i * 2)) < SIZE) ? std::string((1 + (i * 2)), '*') : std::string(SIZE * 2 - (1 + (i * 2)), '*')) << endl;
    }
 
    printf("powered by: ARJAY VICENTE");
}

Monday, July 23, 2018

Swap Two Numbers in C Using Pointers

In this article I would like to share with you a sample program that will swap the two numbers using Pointers in C.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.


Program Listing

swap.c

 #include <stdio.h> 
 
 int swap(int *x, int *y, int t); 
 
 main { 

 int x=0,y=0,t=0; 

 x=20; y=30; t=40; 

 printf(“\n The original value of x: %d”,x); 
 printf(“\n The original value of y: %d”,y); 
 printf(“\n The original value of t: %d”,t); 
 printf(“\nTheir values after calling the function and”); 
 swap(&x,&y,t);
 printf(“\ntheir effect when passed by reference/pointers”); 
 printf(“\n x+1 = %d”,x+1); 
 printf(“\n y+1 = %d”,y+1);
 printf(“\n t+1 = %d”,t+1); 
 getch(); 
 }  

  int swap(int *x, int *y, int t) 
  { 
  t = *x; 
  *x = *y; 
  *y = t;
  } 




Tuesday, July 10, 2018

Area of the Circle Solver in C

In this article I would like to share with you a simple program to solve the are of the circle using C language.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.


Program Listing

circle.c


#include <stdio.h> 

#define Pi 3.1416 

main() {  
 int r;   
 float A; 
 printf(“\n Enter the radius:”); 
 scanf(“%d”,&r); A=Pi*r*r; 
 printf(“\n The area:%f”,A); 
 return 0;
 }   

Sum of Two Number in C

A very simple program to ask the user to give two numbers and then our program will compute the sum of the two numbers using C language.


I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.


Program Listing.

sum.c


#include <stdio.h> 

main()
 {    

 int sum, n1,n2;     

 printf(“\n Enter two nos.”);   
 scanf(“%d%d”,&n1,&n2);   
 sum=n1+n2;  
 printf(“\n The sum: %d”,sum);  
return 0;
}   

Creates random numbers in a given file in C

In this sample program it will create a random numbers in a given file in C.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

random.c

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

void main( )
{
FILE *fp ;
char str [ 67 ] ;
int i, noofr, j ;

clrscr( ) ;

printf ( "Enter file name: " ) ;
scanf ( "%s", str ) ;

printf ( "Enter number of records: " ) ;
scanf ( "%d", &noofr ) ;

fp = fopen ( str, "wb" ) ;
if ( fp == NULL )
{
printf ( "Unable to create file." ) ;
getch( ) ;
exit ( 0 ) ;
}

randomize( ) ;

for ( i = 0 ; i < noofr ; i++ )
{
j = random ( 1000 ) ;
fwrite ( &j, sizeof ( int ), 1, fp ) ;
printf ( "%d\t", j ) ;
}

fclose ( fp ) ;

printf ( "\nFile is created. \nPress any key to continue." ) ;

getch( ) ;
}

Linear search in a unsorted array in C

Here is a simple program in C that I would like to share with you guys a linear search in a unsorted array. The code is very simple and shows how to use C language in Linear Searching.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

linear.c

#include <stdio.h>
#include <conio.h>

void main( )
{
int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90, 3 } ;
int i, num ;

clrscr( ) ;

printf ( "Enter number to search: " ) ;
scanf ( "%d", &num ) ;

for ( i = 0 ; i <= 9 ; i++ )
{
if ( arr[i] == num )
break ;
}

if ( i == 10 )
printf ( "Number is not present in the array." ) ;
else
printf ( "The number is at position %d in the array.", i ) ;

getch( ) ;
}

Linear search in a sorted array in C

Here is a simple program in C that I would like to share with you guys a linear search in a sorted array. The code is very simple and shows how to use C language in Linear Searching.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

linear.c

include <stdio.h>
#include <conio.h>

void main( )
{
int arr[10] = { 1, 2, 3, 9, 11, 13, 17, 25, 57, 90 } ;
int i, num ;

clrscr( ) ;

printf ( "Enter number to search: " ) ;
scanf ( "%d", &num ) ;

for ( i = 0 ; i <= 9 ; i++ )
{
if ( arr[9] < num || arr[i] >= num )
{
if ( arr[i] == num )
printf ( "The number is at position %d in the array.", i ) ;
else
printf ( "Number is not present in the array." ) ;
break ;
}
}

getch( ) ;
}

Sunday, July 8, 2018

Simple Product Information System in C++

A very simple program that I wrote using C++ to demonstrate the use of setprecision function in iomanip library of C++ and to show very basic inventory system written in C++ I use this example in my C++ programming class here in my hometown in Bacolod City, Negros Occidental Philippines. What does the program will do is to ask the user the product name, individual product cost, quantity of the product and then our program will compute the total cost of the product.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.




Sample Program Output



Program Listing

inventory.cpp


#include <iostream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main()
{
string product;
float price=0.00;
int quantity=0;
float total_cost=0.00;
cout << "Simple Product Information System";
cout << "\n\n";
setprecision(2);
cout << "Give Product Name : ";
getline(cin,product);
cout << "Product Price : ";
cin >> price;
cout << "Product Quantity : ";
cin >> quantity;
total_cost = (price * quantity);
cout << "\n\n";
cout << "===== Display Report =====";
cout << "\n\n";
cout << "Product Name   :     " << product << "\n";
cout << "Product Price  : PHP " << price << "\n";
cout << "Quantity       :     " << quantity << "\n";
cout << "\n\n";
cout << "Total Cost     : PHP " << total_cost;
cout << "\n\n";
cout << "End of Program";
cout << "\n\n";
system("pause");
}





Sunday, July 1, 2018

Addition and Product of Two Numbers in C++

In this article I would like to share with you a programming activity that I prepare to my students in my class in computer programming 1 teaching c++ to find the sum and product of two numbers and allows the user to re run again the program. I am using Dev C++ in writing this program I hope you will find my work useful.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.




Sample Program Output


Program Listing

add_product.cpp


#include <iostream>
#include <stdlib.h>

using namespace std;


int main()
{
int a,b,sum,product;
char reply;
do {
system("cls");
cout <<"\tAddition and Product of Two Numbers in C++";
cout << "\n\n";
cout << "\t Created By Mr. Jake R. Pomperada, MAED-IT";
cout << "\n\n";
cout << "Enter First Value  : ";
cin >> a;
cout << "Enter Second Value : ";
cin >> b;
sum = (a+b);
product = (a * b);
cout << "\n\n";
cout <<"The sum of " << a << " and " << b << " is " << sum << ".";
cout << "\n\n";
cout <<"The product of " << a << " and " << b << " is " << product << ".";
cout << "\n\n";
cout << "Do you want to quit? [Y] for YES  and  [N] for NO : ";
    cin >> reply;
}  while (reply == 'n' || reply == 'N');
   cout << "\n\n";
   cout << "\t Thank you for using this software";
   cout <<"\n\n";
   cout << "\t End of Program";
   cout << "\n\n";
}