Pages

Showing posts with label While Loop. Show all posts
Showing posts with label While Loop. Show all posts

Friday, 30 August 2013

Simple Grading System Using Turbo-C or C-Language

This Project is develop using Turbo-C, the project compute the semester grade of student  it can identify if the student is Failed or Passed. The coding of said project is using of different programming operators and logical statement like (IF-Else Statement), (Do-While Loop) and etc.


Project Specification
Programming Language Use: Turbo-C
Version: Any Version: Any Version of Turbo-C Console

Here is the Code:

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

int main()
{
clrscr();
char stnum,lname,fname,mname,chc;
float q1,q2,psa,exam;
float q_eq,psa_eq,exam_eq;
float q_percent,psa_percent,exam_percent,lec_grade,lab_grade,sem_grade;
int x=5;
start:
clrscr();
gotoxy(x+20,2);    printf("ACLC COLLEGE");
gotoxy(x+24,3);    printf("GENSAN");
gotoxy(x+20,4);    printf("PERIODIC SHEET");

gotoxy(x,8);    printf("Student Number:");
gotoxy(x,10);    printf("Last Name:");
gotoxy(x,12);    printf("Midle Initial:");
gotoxy(x,14);    printf("First Name:");

    /*for Prelim-Lecture*/
gotoxy(x,16);    printf("_________________________________");
gotoxy(x,18);    printf("Prelim (Lecture)");
gotoxy(x+3,20);    printf("Quiz1 (Over 20):");
gotoxy(x+3,22);    printf("Quiz2 (Over 20):");
gotoxy(x+3,24);    printf("PSA (Over 100)  :");
gotoxy(x+30,22);    printf("Quiz Equivalent:");    gotoxy(x+55,22);    printf("Percentage:");
gotoxy(x+30,24);    printf("PSA Equivalent :");     gotoxy(x+55,24);    printf("Percentage:");
gotoxy(x+3,26);        printf("Exam (Over 50):");
gotoxy(x+30,26);    printf("Exam Equivalent:");    gotoxy(x+55,26);    printf("Percentage:");
gotoxy(x,28);        printf("Lecture Grade(60%):");
       /*for Prelim-Laboratory*/
gotoxy(x,29);    printf("_________________________________");
gotoxy(x,31);    printf("Prelim (Laboratory)");

gotoxy(x+3,33);    printf("Quiz1 (Over 20):");
gotoxy(x+3,35);    printf("Quiz2 (Over 20):");
gotoxy(x+3,37);    printf("PSA (Over 100) :");
gotoxy(x+30,35);    printf("Quiz Equivalent:");    gotoxy(x+55,35);    printf("Percentage:");
gotoxy(x+30,37);    printf("PSA Equivalent :");     gotoxy(x+55,37);    printf("Percentage:");
gotoxy(x+3,39);        printf("Exam (Over 50):");
gotoxy(x+30,39);    printf("Exam Equivalent:");    gotoxy(x+55,39);    printf("Percentage:");
gotoxy(x,41);    printf("Laboraoty Grade(40%):");
gotoxy(x,42);        printf("_________________________________");
gotoxy(x+3,45);        printf("Prelim Grade:");    gotoxy(x+30,45);    printf("Remarks:");
gotoxy(x,47);         printf("Try Again[Y/N]:");

    /* for scanf*/

gotoxy(x+20,8);        scanf("%s",&stnum);
gotoxy(x+20,10);    scanf("%s",&lname);
gotoxy(x+20,12);    scanf("%s",&mname);
gotoxy(x+20,14);    scanf("%s",&fname);

        /*for Lecture*/
gotoxy(x+20,20);        scanf("%f",&q1);
gotoxy(x+20,22);        scanf("%f",&q2);

     q_eq=(q1+q2)/40*50+50;     gotoxy(x+47,22);      printf("%.2f",q_eq);
     q_percent=(q_eq*.4);        gotoxy(x+67,22);      printf("%.2f",q_percent);

gotoxy(x+20,24);        scanf("%f",&psa);
psa_eq=((psa/100)*50+50);     gotoxy(x+47,24);      printf("%.2f",psa_eq);
 psa_percent=(psa_eq*.1);        gotoxy(x+67,24);      printf("%.2f",psa_percent);

gotoxy(x+20,26);        scanf("%f",&exam);
exam_eq=((exam/50)*50+50);     gotoxy(x+47,26);      printf("%.2f",exam_eq);
 exam_percent=(exam_eq*.5);        gotoxy(x+67,26);      printf("%.2f",exam_percent);

lec_grade=(q_percent+psa_percent+exam_percent)*.6;        gotoxy(x+20,28);    printf("%.0f%",lec_grade);

    /*for lab*/
gotoxy(x+20,33);        scanf("%f",&q1);
gotoxy(x+20,35);        scanf("%f",&q2);

     q_eq=(q1+q2)/40*50+50;     gotoxy(x+47,35);      printf("%.2f",q_eq);
     q_percent=(q_eq*.4);        gotoxy(x+67,35);      printf("%.2f",q_percent);

gotoxy(x+20,37);        scanf("%f",&psa);
psa_eq=((psa/100)*50+50);     gotoxy(x+47,37);      printf("%.2f",psa_eq);
 psa_percent=(psa_eq*.1);        gotoxy(x+67,37);      printf("%.2f",psa_percent);

gotoxy(x+20,39);        scanf("%f",&exam);
exam_eq=((exam/50)*50+50);     gotoxy(x+47,39);      printf("%.2f",exam_eq);
 exam_percent=(exam_eq*.5);        gotoxy(x+67,39);      printf("%.2f",exam_percent);

lab_grade=(q_percent+psa_percent+exam_percent)*.4;        gotoxy(x+22,41);     printf("%.2f",lab_grade);

sem_grade=lec_grade+lab_grade;        gotoxy(x+17,45);     printf("%.0f%",sem_grade);

if (sem_grade>=75)
{gotoxy(x+38,45);    printf("Passed");}

 else if(sem_grade<=74)
{gotoxy(x+38,45);       printf("Failed");}

gotoxy(x+16,47);
 scanf("%s",&chc);

if (chc=='Y'|| chc=='y')
goto start;
else
{return 0;}

getch();

return 0;
}

Simple Grading System Using Visual Basic.net Console Application

Download Project

Download Code

Project Specification

Programming Language Use: Visual Basic.Net (Console Application)
IDE : Visual Studio 2010 with version 4.0 .net Framework

Here is the Code:

Imports System.Console
Module Module1


    Dim x As Integer = 5
    Dim pGrade, mGrade, pfGrade, fGrade As Integer
    Dim name, gender, Course, subject, sem_grade, remarks, chc, pass As String
    Dim q1, q2, cs, exam, grade As Integer
    Dim term_grade As Integer
    Dim prelim, midterm, pre_final, final, equi1 As Integer
    Dim equi As Decimal


    Sub Main()
        Clear()
        Title = "Grading System"
        Call student_info()
        Call result()
        Call made()

        'for student_info
        SetCursorPosition(Len("name:") + x + 1, 5)
        name = ReadLine()
        SetCursorPosition(Len("gender:") + x + 1, 6)
        gender = ReadLine()
        SetCursorPosition(Len("course:") + x + 1, 7)
        Course = ReadLine()
        SetCursorPosition(Len("subject:") + x + 1, 8)
        subject = ReadLine()






        'for made=prelim
        SetCursorPosition(Len("Q1:") + x, 14)
        q1 = ReadLine()
        SetCursorPosition(Len("Q2:") + x, 15)
        q2 = ReadLine()
        SetCursorPosition(Len("CS:") + x, 16)
        cs = ReadLine()
        SetCursorPosition(Len("Exam:") + x, 17)
        exam = ReadLine()

        'compute

        pGrade = (((q1 + q2) / 2) * 0.2) + (cs * 0.2) + (exam * 0.6)
        SetCursorPosition(Len("Grade:") + x, 18)
        Write(pGrade.ToString)


        'for made=midterm
        SetCursorPosition(Len("Q1:") + x + 15, 14)
        q1 = ReadLine()
        SetCursorPosition(Len("Q2:") + x + 15, 15)
        q2 = (ReadLine())
        SetCursorPosition(Len("CS:") + x + 15, 16)
        cs = ReadLine()
        SetCursorPosition(Len("Exam:") + x + 15, 17)
        exam = ReadLine()

        mGrade = (((q1 + q2) / 2) * 0.2) + (cs * 0.2) + (exam * 0.6)
        SetCursorPosition(Len("Grade:") + x + 15, 18)
        Write(mGrade.ToString)


        'for made=prefinal
        SetCursorPosition(Len("Q1:") + x + 30, 14)
        q1 = ReadLine()
        SetCursorPosition(Len("Q2:") + x + 30, 15)
        q2 = ReadLine()
        SetCursorPosition(Len("CS:") + x + 30, 16)
        cs = ReadLine()
        SetCursorPosition(Len("Exam:") + x + 30, 17)
        exam = ReadLine()

        pfGrade = (((q1 + q2) / 2) * 0.2) + (cs * 0.2) + (exam * 0.6)
        SetCursorPosition(Len("Grade:") + x + 30, 18)
        Write(pfGrade.ToString)


        'for made=final
        SetCursorPosition(Len("Q1:") + x + 45, 14)
        q1 = ReadLine()
        SetCursorPosition(Len("Q2:") + x + 45, 15)
        q2 = ReadLine()
        SetCursorPosition(Len("CS:") + x + 45, 16)
        cs = ReadLine()
        SetCursorPosition(Len("Exam:") + x + 45, 17)
        exam = ReadLine()


        fGrade = (((q1 + q2) / 2) * 0.2) + (cs * 0.2) + (exam * 0.6)
        SetCursorPosition(Len("Grade:") + x + 45, 18)
        Write(fGrade.ToString)

        sem_grade = (pGrade * 0.2) + (mGrade * 0.2) + (pfGrade * 0.2) + (fGrade * 0.4)
        SetCursorPosition(Len("Semestral Grade:") + x + 30, 5)
        Write(sem_grade.ToString)

        If sem_grade = 75 Or sem_grade = 76 Then
            equi = 3.0
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 77 Or sem_grade = 78 Or sem_grade = 79 Then
            equi = 2.75
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 80 Or sem_grade = 81 Or sem_grade = 82 Then
            equi = 2.5
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 83 Or sem_grade = 84 Or sem_grade = 85 Then
            equi = 2.25
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 86 Or sem_grade = 87 Or sem_grade = 88 Then
            equi = 2.0
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 89 Or sem_grade = 90 Or sem_grade = 91 Then
            equi = 1.75
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 92 Or sem_grade = 93 Or sem_grade = 94 Then
            equi = 1.5
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 95 Or sem_grade = 96 Or sem_grade = 97 Then
            equi = 1.25
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")
        ElseIf sem_grade = 98 Or sem_grade = 99 Or sem_grade = 100 Then
            equi = 1.0
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")

        ElseIf sem_grade < 75 Then
            equi = 5.0
            SetCursorPosition(Len("Equivalent:") + x + 30, 6)
            Write(equi, "{0.00}")

        End If



        If sem_grade >= 75 Or sem_grade <= 100 Then
            SetCursorPosition(Len("Remarks:") + x + 30, 7)
            Write("Passed")
        ElseIf sem_grade < 75 Then
            SetCursorPosition(Len("Remarks:") + x + 30, 7)
            Write("Failed")
        Else
            SetCursorPosition(Len("Remarks:") + x + 30, 7)
            Write("Unknown")

        End If

        Call all()
        ReadLine()
    End Sub
    Private Sub student_info()

        SetCursorPosition(x, 5)
        Write("Name:")
        SetCursorPosition(x, 6)
        Write("Gender:")
        SetCursorPosition(x, 7)
        Write("Course:")
        SetCursorPosition(x, 8)
        Write("Subject:")
        SetCursorPosition(x + 30, 5)
        Write("Semestral Grade:")
        SetCursorPosition(x + 30, 6)
        Write("Equivalent:")
        SetCursorPosition(x + 30, 7)
        Write("Remarks:")
        SetCursorPosition(x, 9)
        Write("---------------------------------------------------")

    End Sub
    Private Sub result()
        SetCursorPosition(x, 12)
        Write("Prelim")
        SetCursorPosition(x + 15, 12)
        Write("Midtrem")
        SetCursorPosition(x + 30, 12)
        Write("pre-final")
        SetCursorPosition(x + 45, 12)
        Write("Final")
    End Sub
    Private Sub made()
        SetCursorPosition(x + 15, 14)
        Write("Q1:")
        SetCursorPosition(x + 15, 15)
        Write("Q2:")
        SetCursorPosition(x + 15, 16)
        Write("CS:")
        SetCursorPosition(x + 15, 17)
        Write("Exam:")
        SetCursorPosition(x + 15, 18)
        Write("Grade:")

        'for midterm
        SetCursorPosition(x + 30, 14)
        Write("Q1:")
        SetCursorPosition(x + 30, 15)
        Write("Q2:")
        SetCursorPosition(x + 30, 16)
        Write("CS:")
        SetCursorPosition(x + 30, 17)
        Write("Exam:")
        SetCursorPosition(x + 30, 18)
        Write("Grade:")

        'for pre-final
        SetCursorPosition(x + 45, 14)
        Write("Q1:")
        SetCursorPosition(x + 45, 15)
        Write("Q2:")
        SetCursorPosition(x + 45, 16)
        Write("CS:")
        SetCursorPosition(x + 45, 17)
        Write("Exam:")
        SetCursorPosition(x + 45, 18)
        Write("Grade:")

        'for final
        SetCursorPosition(x, 14)
        Write("Q1:")
        SetCursorPosition(x, 15)
        Write("Q2:")
        SetCursorPosition(x, 16)
        Write("CS:")
        SetCursorPosition(x, 17)
        Write("Exam:")
        SetCursorPosition(x, 18)
        Write("Grade:")
        SetCursorPosition(x, 20)
        Write("Another Entry[Y/N]:")


    End Sub
    Private Sub all()

        SetCursorPosition(Len("Another Entry[Y/N]:") + x + 1, 20)
        chc = ReadLine()

        While chc.ToUpper = "Y".ToUpper
            Call Main()
        End While
        SetCursorPosition(5, 22)
        Write("Press any key to...")
    End Sub
End Module


Sunday, 11 August 2013

How to add items in your Combo Box from Database Connection?


















Imports System.Data.SqlClient

Public Class Adding_itemsOfComboBox_From_Database
    Dim dr As SqlDataReader

    Private Sub Adding_itemsOfComboBox_From_Database_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Using conn = Opencon()
            Dim cmd As New SqlCommand("Select FIRSTNAME from PATIENT_INFO", conn)
            dr = cmd.ExecuteReader
            While dr.Read

                cboClientName.Items.Add(dr(0))
            End While

        End Using
    End Sub
End Class

Note:
      "Using conn=Opencon()" is a function use as the global declaration of Database Connection. Click here to learn about it.