Skip to content

Instantly share code, notes, and snippets.

@ishanbhavsar3
Created January 30, 2022 02:58
Show Gist options
  • Save ishanbhavsar3/d8ed66bb6f853248b7d4af023b84f745 to your computer and use it in GitHub Desktop.
Save ishanbhavsar3/d8ed66bb6f853248b7d4af023b84f745 to your computer and use it in GitHub Desktop.
import javax.swing.*;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
public class VaccineBookingWindow {
JFrame f;
void main_() throws MalformedURLException {
f = new JFrame();
URL img = new URL("https://upload.wikimedia.org/wikipedia/en/thumb/c/cf/Aadhaar_Logo.svg/250px-Aadhaar_Logo.svg.png");
ImageIcon image = new ImageIcon(img);
JLabel icon = new JLabel(image);
JLabel text = new JLabel("Please keep your Aadhar Card Ready for verification.", SwingConstants.CENTER);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(icon, BorderLayout.CENTER);
panel.add(text, BorderLayout.NORTH);
JOptionPane.showMessageDialog(null, panel, "Aadhar", JOptionPane.PLAIN_MESSAGE);
URL img2 = new URL("https://lh3.googleusercontent.com/pw/AM-JKLUdAPJG4Zxm4Qoe6kE8JCrEam0R9EKNUdnAguWfWqfHsRq3lEOmxNGQN_H9LEy5rZmbHSMeBAdLbdVwJtycBMGGJ9IxNommZdyhJ6ItlP4h3XU0fPPHl2VHKnSVa5NTk-TG89ckzPEJjUv_m1_rYLle=w535-h244-no?authuser=0");
ImageIcon ic = new ImageIcon(img2);
JLabel icon1 = new JLabel(ic);
JPanel panel1 = new JPanel();
panel1.setLayout(new BorderLayout());
panel1.add(icon1, BorderLayout.CENTER);
JOptionPane.showMessageDialog(null, panel1, "InVaxPort", JOptionPane.PLAIN_MESSAGE);
String name = JOptionPane.showInputDialog("Please enter your name in the box below:");
URL img3 = new URL("https://researchresearch-news-wordpress-media-live.s3.eu-west-1.amazonaws.com/2020/04/covid-19_coronavirus_vaccine_needle-738x443.jpg");
ImageIcon ic1 = new ImageIcon(img3);
JLabel icon2 = new JLabel(ic1);
JLabel text3 = new JLabel("Press ok to enter InVaxPort, "+name, SwingConstants.CENTER);
JPanel panel2 = new JPanel();
panel2.setLayout(new BorderLayout());
panel2.add(icon2, BorderLayout.CENTER);
panel2.add(text3, BorderLayout.SOUTH);
JOptionPane.showMessageDialog(null, panel2, "Welcome to India's initiative.", JOptionPane.PLAIN_MESSAGE);
String gender = JOptionPane.showInputDialog("Please specify your gender (MALE/FEMALE/OTHER)");
String strgn = gender.toUpperCase();
if(!strgn.equals("MALE") && !strgn.equals("FEMALE") && !gender.equals("OTHER"))
{
for(int h = 1;h<10;h++)
{
String gender1 = JOptionPane.showInputDialog("Please specify your gender (MALE/FEMALE/OTHER)");
if(gender1.equals("MALE") || gender1.equals("FEMALE") || gender1.equals("OTHER"))
break;
}
}
String ageinp = JOptionPane.showInputDialog("Please enter your age");
int age = Integer.parseInt(ageinp);
if (age<18)
{
JOptionPane.showMessageDialog(f,"Sorry, you are not yet eligible to be vaccinated");
System.exit(0);
}
String dinp = JOptionPane.showInputDialog("Is this your 1st Dose or 2nd Dose (Type 1 or 2)");
int dose = Integer.parseInt(dinp);
if(dose==2)
{
String dos= JOptionPane.showInputDialog("Enter the name of the vaccine which you took.");
}
if(dose!=1 && dose!=2)
{
for (int d = 1;d<101;d++)
{
String dose1_ = JOptionPane.showInputDialog("This is your 1st or 2nd Dose? (Type 1 or 2)");
int dose1 = Integer.parseInt(dose1_);
if(dose1==2)
{
System.out.print("Enter the name of the vaccine which you took. ");
String dos= JOptionPane.showInputDialog("Enter the name of the vaccine which you took.");
break;
}
if(dose1==1)
{
break;
}
}
}
String mnum = JOptionPane.showInputDialog("Please enter your 10 digit mobile number");
long m_num = Long.parseLong(mnum);
long tem = m_num;
long digit = 0;
while (tem!=0)
{
long pick_last = tem % 10;
digit++;
tem = tem / 10;
}
for(int j = 1;j<=100;j++)
{
if (digit !=10)
{
String m_num2 = JOptionPane.showInputDialog("Please input only a ten digit mobile number when asked for it : ");
m_num = Long.parseLong(m_num2);
int digit2 = 0;
long tem2 = m_num;
long pl1 = 0;
while (tem2!=0){
pl1 = tem2 % 10;
digit2++;
tem2 = tem2/ 10;
}
if(digit2==10) {
break;
}
}
}
String aadinp = JOptionPane.showInputDialog("Please enter your Aadhar Card Number.");
long aadhar = Long.parseLong(aadinp);
long tem12 = aadhar;
long digit12 = 0;
while (tem12!=0)
{
long pick_last = tem12 % 10;
digit12++;
tem12 = tem12 / 10;
}
for(int j = 1;j<=100;j++)
{
if (digit12 !=12)
{
String aadinp2 = JOptionPane.showInputDialog("Please input only a 12 digit Aadhar card number when asked for it : ");
aadhar = Long.parseLong(aadinp2);
int digit4 = 0;
long tem4 = aadhar;
long pl2 = 0;
while (tem4!=0){
pl2= tem4 % 10;
digit4++;
tem4 = tem4/ 10;
}
if(digit4==12)
{
break;
}
}
}
String pinin = JOptionPane.showInputDialog("Please enter your pincode.");
// counting number of digits.
long pin = Long.parseLong(pinin);
long temp1=pin;
int digit_=0;
while (temp1!=0)
{
long picklast = temp1 % 10;
digit_++;
temp1 = temp1 / 10;
}
//
if(digit_!= 6)
{
for(int i = 1;i<=10;i++)
{
String pinin_ = JOptionPane.showInputDialog("Please enter your pincode.");
pin = Long.parseLong(pinin_);
int digit1 = 0;
long temp0 = pin;
long pl = 0;
while (temp0!=0){
pl = temp0 % 10;
digit1++;
temp0 = temp0/ 10;
}
if(digit1==6) {
break;
}
}
}
double temp10 = Math.random()*1000;
int OT = (int)temp10;
String a = JOptionPane.showInputDialog("Please re-input the given code and press ok to prove that you are a human\n "+OT);
int OTP = Integer.parseInt(a);
if(OT==OTP)
{
JOptionPane.showMessageDialog(f,"Registration Successful!");
}
else{
for(int o = 1;o<10;o++)
{
double temp11 = Math.random()*1000;
int OP = (int)temp10;
String a11 = JOptionPane.showInputDialog("Please re-input the given new code and press ok to prove that you are a human\n "+OT);
int otp = Integer.parseInt(a11);
if(otp==OP)
{
JOptionPane.showMessageDialog(f,"Registration successful.");
}
break;
}
}
double temp13 = Math.random()*1000000;
long cod = (long)temp13;
JOptionPane.showMessageDialog(f,"\n\nWelcome to the Confirmation Page of InVaxPort, "+name
+"\nYou identify as a "+gender+"\nYour age is "+age+" years."+"\nYour Aadhar card number is "+aadhar+
"\nYour mobile number is "+m_num+"\nYour pin code is "+pin);
String b = JOptionPane.showInputDialog("""
Time Slot:\s
1 --> 10:00 a.m. to 12:00 p.m.
2 --> 12:00 p.m. to 2:00 p.m.
3 --> 2:00 p.m. to 4:00 p.m.
4 --> 4:00 p.m. to 6:00 p.m.Enter the time slot in which you are available (Enter the number 1, 2, 3 or 4 to choose.""");
int time = Integer.parseInt(b);
JOptionPane.showMessageDialog(f,"Beneficiary Code: "+cod);
JOptionPane.showMessageDialog(f,"WARNING! Please do not share this Beneficiary code with anyone else.\n" +
"Provide this code at the nearest government vaccination center to receive the vaccine.");
}
public static void main(String[] args) throws MalformedURLException {
VaccineBookingWindow call = new VaccineBookingWindow();
call.main_();
}
}
// Copyright (c) 2021 - 2022 Ishan Ketan Bhavsar & Mohak Rasik Dave
// Free for distribution under the MIT License
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment