Sunday, 29 January 2023
Java Program to find the Prime numbers using values from Terminal as input through (String [] args)
Sunday, 15 January 2023
Day Name Finder using C++
Sunday, 8 January 2023
Airline Reservation System Project in C++
#include<iostream>
#include<conio.h>
#include<fstream>
#include<stdlib.h>
#include<iomanip>
using namespace std;
class flightDetails
{
double flamt;
char flnum[100], flname[100], flfrom[200], usdestin[200], fltime[100];
int columnID;
char opt;
public:
void fldisplay();
void flgetdata();
};
flightDetails f;
void flightDetails::fldisplay()
{
fstream file2;
file2.open("flightDetails1234.txt",ios::in | ios::out | ios::binary);
if(!file2)
{
cout << "\n File Not Found!!!!";
file2.close();
return;
}
cout << "\n------------------------------------------------------------------------------------------" << endl;
cout << "\n| columnID | "<< "| Flight No |"<< "| From |"<< "| To |"<< "| Flight Time |"<< "| Amount |" << endl;
file2.seekg(0,ios::beg);
while (file2.read((char *)&f, sizeof(f)))
{
cout<< " | " <<columnID << " | " << flnum << " | " << flfrom << " | " << usdestin << " | " << fltime << " | " << flamt << " | " << endl;
cout<< "----------------------------------------------------------------------------------------------------------------------------------------------" << endl;
}
file2.close();
}
void flightDetails::flgetdata()
{
fstream file; //will be able to read and write into the file
int flag = 0;
columnID=1;
file.open("flightDetails1234.txt", ios::in | ios::app | ios::binary);
file.seekp(0, ios::end);
cout << "\n Enter Flight Number: ";
cin>>flnum;
cout << "\n Enter Flight Name: ";
cin>>flname;
cout << "\n Enter Flight From: ";
cin>>flfrom;
cout << "\n Enter Flight destination: ";
cin>>usdestin;
cout<< "\n Enter Flight Time (in HH:MM format): ";
cin>>fltime;
cout << "\n Enter Flight amout: ";
cin >> flamt;
cout << "\n Enter Flight Availability: (A (Available) / N (Not Available)): ";
cin >> opt;
if (opt == 'A' || opt == 'a')
{
if(file)
{
file.seekp(0,ios::end);
file.write((char *)&f,sizeof(f));
//file<<columnID<<setw(10)<<flnum<<setw(20)<<flname<<setw(20)<<left<<flfrom<<left<<usdestin<<left<<setw(20)<<fltime<<left<<setw(20)<<flamt<<endl;
flag = 1;
cout << " Successfully Added into the file...."<<endl;
}
else
{
cout << "Unable to Open / Write into the File." << endl;
}
if (flag == 1)
{
columnID += 1;
}
}
else
cout << "The Flight Is Not Available" << endl;
file.close();
fldisplay();
}
int main(void)
{
cout << "\nWelcom to Airlines Reservation System";
cout << "\n---------------------------------------------------";
f.flgetdata();
system("pause");
return 0;
}
Monday, 2 January 2023
Magic Matrices using C language
#include<stdio.h>
#include<conio.h>
int main(void){
char ans;
int a[15][15],i,j,k,l,m,x,y,n;
do{
ejaz:
//clrscr(); //this line will work in TurboC++ to clear the console
printf("\n Enter any odd number b/n 3 to 15 to get magic matrix: ");
scanf("%5d",&n);
if(n%2==0||n<3||n>15)
goto ejaz;
for(j=(n-1)/2,k=1,i=0,l=0;l<n;l++){
for(m=1;m<=n;i--,j--,m++,k++){
if(j<0)
j=n-1;
if(m<=n&&i+1==0)
i=n-1;
a[i][j]=k;
}
i+=2;
j++;
}
printf("\n\n");
for(y=3,i=0;i<n;i++,y+=3){
for(x=5,j=0;j<n;j++,x+=5){
//gotoxy(x,y); //gotoxy can give printing location to curser in TurboC++
printf("%5d",a[i][j]);
}
printf("\n\n"); // this line does not needed in TurboC++, the gotoxy is all it needed
}
printf("\n Want to continue y/n: ");
fflush(stdin); // fflush(stdin) is uesd to clear the garbage from standard input stream
ans=getchar();
}while(ans=='y'||ans=='Y');
//getch(); //this line will work in TurboC++ to hold screen of the console
}