Tuesday 4 October 2016

C++ OOP write a program to input a date print on the screen by using class

Code:-


#include<iostream>
#include<conio.h>
using namespace std;

class Time{
private:
int hour;
int minute;
int seconds;
public:
int flag = 0;

void get_Time(){
if (flag == 0)
{
cout << "Enter time Please _:_:_";
flag = 1;
}
if (flag == 1)
{
cin >> hour;
if (hour < 24)
{
flag = 2;
cout << "hours is finished";
}
else
{
flag = 1;
get_Time();
}
}
if (flag == 2)
{
cin >> minute;
if (minute <= 60)
{
flag = 3;

cout << "minute is finished";
}
else
{
flag = 2;
get_Time();
}
}
if (flag == 3)
{
cin >> seconds;
if (seconds <= 60)
{
flag = 4;

cout << "seconds is finished";
}
else
{
flag = 3;
get_Time();
}
}
}

void set_Time(){
cout << "Time is " << hour << ":" << minute << ":" << seconds;
}
};

void main()
{
Time tC;
tC.get_Time();
tC.set_Time();

_getch();
}


output:-


Thursday 29 September 2016

C++ Convert 4 character plain text to cypher text

Always remember to get desired output from machine you have to first provide significant solutions to respective problems so i proposed following option

first thing is very important to create algo & implement Algo in any language . I don't want to discuss in depth but main purpose of this program is to accomplish basic working of simple text(such as string) to cypher(desired alphabates encryption) its not efficient algo but i have written for poor programmers. You know copy paste programmers are qualified professional degree holder but behind the scene they are nothing more than copy paste so i suggest my students , followers don't learn programming by heart just give some precious honour time for it which leads you to get huge grip in easly making of logical solution for simple programs but perform logical problems that are part of programming . every one can write Code
with perfect logic & unsatisfactory logic can leads to time waste results


 have lack of interest in programming they just want to get basic idea behind the logic.


i initialized & declared character Array of 4 size.
use loop to get single character in each array index
the key_size is used to apply on each character to apply cypher to get desired cyper character

for example

plain text

a               b                        c                    d

which means

array[0] has character a
array[1] has character b
array[2] has character c
array[3] has character d

key_size = 2 let example

desired output must be 


c          d           e            f             





Code:-

#include <iostream>
#include<conio.h>
using namespace std;

void main()
{
char ch[4]; //
int i = 0;
cout << "Please enter the plan text : ";
while (i<4)
{
cout << endl << "enter the letter # :" << i << endl;
cin >> ch[i];
i++;
}
char Start_ch = 'a';
char End_ch = 'z';
int KeySize = 2;

cout << "Please enter the Key Size : ";
cin >> KeySize;
char ab = 'x';

/*to get the cypher text we need to perform loop on all character present in character array*/
for (int j = 0; j<4; j++)
{
/*we initialize the variable integer with i that can start with 0 for each letter to perform logic*/
int i = 1;
while (i <= KeySize)
{
/* character is less then z letter it will remain continue*/
if (ch[j]<'z')
{
  ab = ch[j]; // get the current character from array to character variable that is temp
ab++;  //increment the array variable 1 to against keysize
ch[j] = ab;  //override the exsisting variable with increment character variable
i++;
}
/*the character who exceeds the letter z then it is reset from a to onward */
else if (ch[j] == 'z')
{
ch[j] = 'a';
i++;
}
}
}
cout << endl;
cout << "Cypher text is as under : ";
for (int i = 0; i<4; i++){
cout << ch[i];
}
_getch();
}

Output:-


Tuesday 26 July 2016

C++ GPA CALCULATOR

Step # 1 

first you have to view my previous program that is basic C++ GPA calculator available on following link

C++ GPA Calculator

Step # 2

this program is consists of following attributes.
1) pointer array.
2) function call by value & inline function.

i dont want to describe program briefly this program is consisted of  question as under

User is asked to enter 3 subject marks out of 100 

marks greater then 88 but less then 100 award grade must be A with 4.00 points
marks greater then 80 but less then 87 award grade must be B+ with 3.50 points
marks greater then 73 but less then 79 award grade must be B with 3.00 points
marks greater then 66 but less then 72 award grade must be C+ with 2.50 points
marks greater then 60 but less then 66 award grade must be C with 2.00 points
marks greater then 50 but less then 59 award grade must be D with 4.00 points
else you are fail in course

according to above brief option logic is simple 


Code:-


#include<iostream>

#include<conio.h>

using namespace std;



float getGpa(float *marks,float *subjects)

{
float result = 0;

for (int i = 0; i < 3; i++)
{
float points = 0;
if ((*marks + i)>=87)
{
points = 4;
}
else if ((*marks + i) >= 80 && (*marks + i) < 87)
{
points = 3.5;
}

else if ((*marks + i)>=72 && (*marks + i) < 80)

{
points = 3.0;
}
else if ((*marks + i)>=66 && (*marks + i) < 72)
{
points = 2.5;
}
else if ((*marks + i) >= 60 && (*marks + i) < 66)
{
points = 2.0;
}
else
{
points = 0;
}


result += points;

}

float ab;

ab = (result / 3);
return ab;
}


void main()

{
float marks[3];
float credits[3];
float *ptr;
float *_ptr;
for (int i = 0; i < 3; i++)
{
cout << "Enter marks of subject number " << i << " = ";
cin >> marks[i];

cout << "Enter credit of subject number " << i << " = ";
cin >> credits[i];
}

ptr = marks; _ptr = credits;

cout << "Gpa is = " << getGpa(ptr, _ptr);
_getch();
}


OUTPUT





ALL RIGHTS RESERVED TO UMAR JAVED 

c# , c++ , WORDPRESS , XAMARIN DEVELOPER