I made a bookshop type of program for my 1st term final , which the code is way to big and it involves quite alot things , so check this , my teacher gave me that as a challange , you just type any dd/mm/yyyy and It will tell you what day it was on that date
#include <iostream.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int findDay(int date, int month, int year);
int main()
{
int date, month, year;
clrscr();
char dayName[7][10] =
{"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
cout << "\n Enter the date (1-31): ";
cin >> date;
cout << "\n Enter the month (1-12): ";
cin >> month;
if(date<=31 && month==1 || date<=28&& month==2 || date<=31&& month==3 || date<=30&& month==4||date<=31&& month==5||date<=30 && month==6||
date<=31&& month==7 || date<=31 && month==8 || date<=30 && month==9 || date<=31 && month==10 ||date<=30 && month==11 ||date<=31 && month==12)
{
cout << "\n Enter the year (Non-Negative): ";
cin >> year;
}
else {
cout<<"\n Error ";
exit(0);
}
int day = findDay(date, month, year);
cout << endl << "The day is " << dayName[day] << "." << endl;
getch();
return 0;
}
int findDay(int d, int m, int y)
{
if (m == 1 || m == 2) y -= 1;
if (m < 3) m += 12;
return (d + 2*m + (3*(m+1)/5) + y + (y/4) - (y/100) + (y/400) + 2) % 7;
}
and this is a virtual ATM software I made :D
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define db 20000
struct atmp1 {
int fb;
int wa;
char pcode[20];
char n1[20];
char n2[20];
char n3[20];
char r;
};
struct case1 {
char fc1;
char fc1a;
};
struct case2 {
char fc2;
char fc2a;
};
struct case3 {
char fc3;
char fc3a;
};
struct case4 {
char fc4;
char fc4a;
};
struct case5 {
char fc5;
char fc5a;
};
struct case6 {
char fc6;
char fc6a;
};
struct case7 {
char fc7;
char fc7a;
};
void main()
{
atmp1 st;
case1 a;
case2 b;
case3 c;
case4 d;
case5 e;
case6 f;
case7 g;
int op;
clrscr();
cout<<"\n \t Create Account \n"; //default balance 20,000
cout<<"\n Enter Desired Login I.D : ";
cin>>st.n1;
cout<<"\n Enter Desired Pin Code : ";
cin>>st.pcode;
clrscr();
while(1)
{
cout<<"\n \t Welcome to Customer Menu \n ";
cout<<"\n 1 ---- Withdraw Cash \n";
cout<<"\n 2 ---- Cash Transfer \n"; // Main Menu
cout<<"\n 3 ---- Deposit Cash \n";
cout<<"\n 4 ---- Display Balance \n";
cout<<"\n 5 ---- Exit \n ";
cout<<"\n Please Select One Of The Above Options : ";
cin>>op;
switch(op)
{
case 1: // Menu of Withdrawl Cash
char op1;
cout<<"\n Select The Mode of Withdrawl Cash As Follows : \n";
cout<<"\n a) Fast Cash \n";
cout<<"\n b) Normal Cash \n";
cout<<"\n Please Select A mode Of Withdrawl : ";
cin>>op1;
clrscr();
switch(op1)
{
case 'a':
int m1;
cout<<"\n Fast Cash \n"; // Fast Cash Menu
cout<<"\n 1 --- 500 \n";
cout<<"\n 2 --- 1000 \n";
cout<<"\n 3 --- 2000 \n"; //Options of Fast Cash
cout<<"\n 4 --- 5000 \n";
cout<<"\n 5 --- 10000 \n";
cout<<"\n 6 --- 15000 \n";
cout<<"\n 7 --- 20000 \n";
cout<<"\n Select One Of The Denomiations of Money : ";
cin>>m1;
switch(m1)
{
case 1:
cout<<"\n Do You Really Want To Draw 500 [Y/N] ? ";
cin>>a.fc1;
if(a.fc1=='Y' || a.fc1=='y')
{
cout<<"\n Draw Successful \n";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>a.fc1a;
if(a.fc1a=='Y' || a.fc1a=='y')
{ cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Withdrawn : 500 "<<"\n";
st.fb=db-500;
cout<<"\n New Balance : "<<st.fb<<"\n"; }
if(a.fc1a=='N'|| a.fc1a=='n')
{cout<<"\n Press Any Key To Continue ";
break;} }
if(a.fc1=='N'|| a.fc1=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break;
case 2:
cout<<"\n Do You Really Want To Draw 1000 rs [Y/N] ? ";
cin>>b.fc2;
if(b.fc2=='Y'|| b.fc2=='y')
{
cout<<"\n Draw Successful ";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>b.fc2a;
if(b.fc2a=='Y'|| b.fc2a=='y')
{cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Withdrawn : 1000 \n";
st.fb=db-1000;
cout<<"\n New Balance : "<<st.fb<<"\n";
}
if(b.fc2a=='N'|| b.fc2a=='n')
{cout<<"\n Press Any Key To Continue \n";
break;} }
if(b.fc2=='N'|| b.fc2=='n')
{cout<<"\n Press Any Key To Continue \n";
break;}
break;
case 3:
cout<<"\n Do You Really Want To Draw 2000 rs [Y/N] ? ";
cin>>c.fc3;
if(c.fc3=='Y'|| c.fc3=='y')
{
cout<<"\n Draw Successful \n";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>c.fc3a;
if(c.fc3a=='Y'|| c.fc3a=='y')
{cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Withdrawn : 2000 \n";
st.fb=db-2000;
cout<<"\n New Balance : "<<st.fb<<"\n";
}
if(c.fc3a=='N'|| c.fc3a=='n')
{cout<<"\n Press Any Key To Continue ";
break;} }
if(c.fc3=='N'|| c.fc3=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break;
case 4:
cout<<"\n Do You Really Want To Draw 5000 rs [Y/N] ? ";
cin>>d.fc4;
if(d.fc4=='Y'|| d.fc4=='y')
{
cout<<"\n Draw Successful \n";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>d.fc4a;
if(d.fc4a=='Y'|| d.fc4a=='y')
{cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Withdrawn : 5000 \n";
st.fb=db-5000;
cout<<"\n New Balance : "<<st.fb<<"\n";
}
if(d.fc4a=='N'|| d.fc4a=='n')
{cout<<"\n Press Any Key To Continue ";
break;} }
if(d.fc4=='N'|| d.fc4=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break;
case 5:
cout<<"\n Do You Really Want To Draw 10000 rs [Y/N] ? ";
cin>>e.fc5;
if(e.fc5=='Y'|| e.fc5=='y')
{
cout<<"\n Draw Successful \n";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>e.fc5a;
if(e.fc5a=='Y'|| e.fc5a=='y')
{cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Withdrawn : 5000 \n";
st.fb=db-10000;
cout<<"\n New Balance : "<<st.fb<<"\n";
}
if(e.fc5a=='N'|| e.fc5a=='n')
{cout<<"\n Press Any Key To Continue ";
break;} }
if(e.fc5=='N'|| e.fc5=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break;
case 6:
cout<<"\n Do You Really Want To Draw 15000 rs [Y/N] ? ";
cin>>f.fc6;
if(f.fc6=='Y'|| f.fc6=='y')
{
cout<<"\n Draw Successful \n";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>f.fc6a;
if(f.fc6a=='Y'|| f.fc6a=='y')
{cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Withdrawn : 15000 \n";
st.fb=db-15000;
cout<<"\n New Balance : "<<st.fb<<"\n";
}
if(f.fc6a=='N'|| f.fc6a=='n')
{cout<<"\n Press Any Key To Continue ";
break;} }
if(f.fc6=='N'|| f.fc6=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break;
case 7:
cout<<"\n Do You Really Want To Draw 20000 rs [Y/N] ? ";
cin>>g.fc7;
if(g.fc7=='Y'|| g.fc7=='y')
{
cout<<"\n Draw Successful \n";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>g.fc7a;
if(g.fc7a=='Y'|| g.fc7a=='y')
{cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Withdrawn : 20000 \n";
st.fb=db-20000;
cout<<"\n New Balance : "<<st.fb<<"\n";
}
if(g.fc7a=='N'|| g.fc7a=='n')
{cout<<"\n Press Any Key To Continue ";
break;} }
if(g.fc7=='N'|| g.fc7=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break;
default:
cout<<"\n Invalid Option ";
}
break;
case 'b':
char a,a1;
// int fb,wa; //Normal Cash Menu
cout<<"\n\t Normal Cash \n";
cout<<"\n Enter The Withdrawl Amount : ";
cin>>st.wa;
if(st.wa>db)
{
cout<<"\n Not Enough Balance In Account ";
break;}
cout<<"\n Do You Really Want to Draw : "<<st.wa<<" [Y/N] ?";
cin>>a;
if(a=='Y')
{cout<<"\n Successfully Drawn \n ";
cout<<"\n Do You Want To Print A Receipt [Y/N] ? ";
cin>>a1;}
if(a=='N')
{cout<<"\n Press Any Key To Continue ";
break; }
if(a1=='Y')
{
cout<<"\n Account Name : "<<st.n1<<"\n";
st.fb=db-st.wa;
cout<<"\n Withdrawn : "<<st.wa<<"\n";
cout<<"\n New Balance : "<<st.fb<<"\n";
}
if(a1=='N')
{
cout<<"\n Press Any Key To Continue ";
break;
}
break ;
}
break;
case 2:
int ct,ac33,ac22;
char r;
cout<<"\n \t Cash Transfer \n"; //Cash Transfer Menu
cout<<"\n Enter Amout In Multiples of 500 : "; //amount to be transferred
cin>>ct;
if(ct%500!=0)
{
cout<<"\n Invalid Amount \n";
break;}
else
cout<<"\n Enter Account In Which You Want To Transfer : ";
cin>>ac33;
cout<<"\n Are You Sure You Want To Transfer "<<ct<<" To Account"<<ac33<<" If Yes Please Enter Account Name Again : ";
cin>>ac22;
cout<<"\n Transaction Confirmed \n";
cout<<"\n Do You Want To Print Receipt [Y/N] ? ";
cin>>r;
if(r=='Y' || r=='y')
{cout<<"\n Accout Name : "<<st.n1<<"\n";
cout<<"\n Transaction Made : "<<ct<<"\n";
st.fb=db-ct;
cout<<"\n New Balance : "<<st.fb<<"\n";}
else if(r=='N' || r=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break;
case 3:
int cd;
char rcd1; // Depost Cash Menu
cout<<"\n\t Deposit Cash \n";
cout<<"\n Enter The Cash Amout To Deposit : ";
cin>>cd;
cout<<"\n Cash Deposited Successfully \n";
cout<<"\n Do You Want To Print The Receipt [Y/N] ? ";
cin>>rcd1;
if(rcd1=='Y' || rcd1=='y')
{cout<<"\n Account Name : "<<st.n1<<"\n";
cout<<"\n Deposited Money : "<<cd<<"\n";
st.fb=db+cd;
cout<<"\n New Balance : "<<st.fb<<"\n"; }
else if(rcd1=='N' || rcd1=='n')
{cout<<"\n Press Any Key To Continue ";
break;}
break ;
case 4:
cout<<"\n Your Balance : "<<st.fb;
break;
case 5:
exit(0);
break;
default:
cout<<"\n Invalid Option ";
}
cout<<"\n Do You Wish To See The Menu Again [Y/N] ? ";
cin>>st.r;
if(st.r=='Y' || st.r=='y')
continue;
else if(st.r=='N' || st.r=='n')
exit(0);
}
}