Tuesday, 5 December 2017

HackerRank Solution For Deque-STL in C/C++

Problem:- Deque-STL Discussion | C++ Question | HackerRank solution or deque-stl hackerrank solution or deque c++ example or deque-stl hacker rank program in c++ or double ended queue in c++ using arrays or hackerrank stl or deque hackerrank solution or double ended queue c++ solution or hackerrank c++ solutions or hackerrank c++ domain solutions or c++ practice online or Deque-STL Hacker Rank Solution 

Introduction

Double ended queue or Deque(part of C++ STL) are sequence containers with dynamic sizes that can be expanded or contracted on both ends (either its front or its back). The member functions of deque that are mainly used are:

Deque Template:

std::deque<value_type>

Declaration:

deque<int> mydeque; //Creates a double-ended queue of deque of int type

Size

int length = mydeque.size(); //Gives the size of the deque

Push

mydeque.push_back(1); //Pushes element at the end
mydeque.push_front(2); //Pushes element at the beginning

Pop

mydeque.pop_back(); //Pops element from the end
mydeque.pop_front(); //Pops element from the beginning

Empty

mydeque.empty() //Returns a boolean value which tells whether the deque is empty or not

Task

Given a set of arrays of size N and an integer K, you have to find the maximum integer for each and every contiguous subarray of size N for each of the given arrays.

Explanation:- Deque-STL is a double-ended queue. Logic is a very simple first number denotes the number of test case's given after that size of an array N and size of a sub-array K is given. Now we have to print the greatest number formed by sub-array. and print the greatest number each time. Let's take an example and try to understand the problem in a simple step. 

Example:-

1
7 4
3 4 5 8 1 4 10

here 1 is the total number of test cases and 7 is the size of an array and 4 is a size of sub-array formed by array, so for a given array sub-array will be {3, 4, 5, 8 }, {4, 5, 8, 1 }, {5, 8, 1, 4 }, {8, 1, 4, 10 }. Now our task is to print the largest number of these sub-array, So finally our output should be {8, 8, 8, 10 }.

Submit Your Solution Here:- Click Here


Solution:-  Deque-STL Hacker Rank Solution in C/C++


#include<bits/stdc++.h>
#include <deque>
using namespace std;

void printKMax(int arr[], int n, int k)
{
    deque<int> De_que;
    int i;
    
    for(i=0; i<k; i++)
    {
        while(!De_que.empty() && arr[i]>=arr[De_que.back()])
{
            De_que.pop_back();
        }
        De_que.push_back(i);
    }
    
    for(i=k; i<n; i++)
{
        cout<<arr[De_que.front()]<<" ";
        
        while(!De_que.empty() && De_que.front()<=i-k)
{
            De_que.pop_front();
        }
        while(!De_que.empty() && arr[i]>=arr[De_que.back()])
{
            De_que.pop_back();
        }
        De_que.push_back(i);
        
    }
    cout<<arr[De_que.front()]<<endl;
}

int main()
{

   int t;
   scanf("%d",&t);
   while(t--) 
   {
      int n,k;
      cin>>n>>k;
       int i;
      int * arr=new int [n];
       for(i=0;i<n;i++)
           cin>>arr[i];
       printKMax(arr, n, k);
       
     }
     return 0;
}

Output:-


HackerRank Solution For Deque-STL


You May Also See



1. Geeksforgeeks Solution For " Count Squares "

2. Geeksforgeeks Solution For " Square Divisors "

3. Geeksforgeeks Solution For " Sum of divisors "

4. Geeksforgeeks Solution For " Different ways to Spell a Number "

5. Geeksforgeeks Solution For " Maximize sum after K negations "
Read More »

Friday, 24 November 2017

HackerRank Solution For Day 29: Bitwise AND

Problem:- hacker rank-30-Days-of-Code/Day-29-Bitwise-AND or Day 29: Bitwise AND Discussion | 30 Days of Code or Day 29: Bitwise AND or Day 29 Bitwise AND! hacker rank or Hackerrank Day 29: Bitwise AND or Hackerrank Day 29: Bitwise AND solution or Hacker rank, 30 Days of Code Challenges or bitwise and hacker rank or day 29 hacker rank or bitwise and hacker rank solution or 30 days of code Java or how to code in hacker rank or bitwise and hacker rank solution.

Task

Given set S = {1, 2, 3, . . . . , N}. Find two integers, A and B (where A<B), from set S such that the value of A&B is the maximum possible and also less than a given integer, K. In this case, & represents the bitwise AND operator.

Basic Operators

Here are some commonly used Java operators you should familiarize yourself with & Bitwise AND (^). This binary operation evaluates to 1 (true) if both operands are true, otherwise 0 (false). In other words:

1 & 1 = 1
1 & 0 = 0
0 & 1 = 0
0 & 0 = 0

| Bitwise Inclusive OR (V). This binary operation evaluates to 1 if either operand is true, otherwise 0 (false) if both operands are false. In other words:

1 | 1 = 1
1 | 0 = 1
0 | 1 = 1
0 | 0 = 0

^ Bitwise Exclusive OR or XOR (⊕). This binary operation evaluates to 1 (true) if and only if exactly one of the two operands is 1; if both operands are 1 or 0, it evaluates to 0 (false). In other words:

1 ^ 1 = 0
1 ^ 0 = 1
0 ^ 1 = 1
0 ^ 0 = 0

~ The unary Bitwise Complement operator flips every bit; for example, the bitwise-inverted 8-bit binary number 01111001 becomes 10000110, and the bitwise-inverted signed decimal integer 8 becomes -9.

Explanation:- As we can see above in Bitwise AND if  1 and 1 then the only condition is true. In this problem, we are taking two input from the user first one in number N and second in K. Now we have to find the all set of number S = {1, 2, 3, . . . . , N}. Let's take an example and try to understand the problem "Bitwise AND" easily. suppose N=5 and K=2 then set S={1, 2, 3, 4, 5}. then the combination is below.

1. A = 1, B = 2; A & B = 0
2. A = 1, B = 3; A & B = 1
3. A = 1, B = 4; A & B = 0
4. A = 1, B = 5; A & B = 1
5. A = 2, B = 3; A & B = 2
6. A = 2, B = 4; A & B = 0
7. A = 2, B = 5; A & B = 0
8. A = 3, B = 4; A & B = 0
9. A = 4, B = 5; A & B = 1
10. A = 4, B = 5; A & B = 4

The maximum possible value of A & B (LINE NUMBER 5) that is also < (K = 2) is 1, so we print 1 on a new line. We continue to check A & B value is maximum and A & B value is less than or equal to the K.

Submit Your Solution Here:- Click Here


Solution:- Day 29: Bitwise AND


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{    
int T, n, k, i, j, val;
cin>>T;
    
while(T>0)
    {    
        int maximum = 0;
        cin>>n>>k;
        
        for (i=1;i<n-1;i++) 
{
            for (j=i+1;j<=n;j++) 
{
                val=i&j;
                           
if (val>maximum&&val<k) 
                    maximum = val;                    
            }    
        }
            cout<<maximum<<endl;
        T--;
    }
return 0;
}

✱ New Feature:- Now You Can Download a Full Code Click Here

How to Download

1. After Clicking Click here it will jump to the new page.
2. You have to just Scroll a page until End.
3. Now click Download Button your File will be Download.

Output:-


HackerRank Solution For Day 29: Bitwise AND



You May Also See


1. Day 24: More Linked Lists

2. Day 25: Running Time and Complexity

3. Day 26: Nested Logic

4. Day 27: Testing

Read More »

Monday, 20 November 2017

Technology: The Change of Life

I am trying to answer these questions- how did technology change our lives or describe the evolution of technology or how does technology help us in our daily life or why technology is good for society or how does technology make our life easier or how does technology improve our lives or how does technology help students
“Technology is a useful servant but a dangerous master” - Christian Lous Lange

As we as a whole know Technology is an assemblage of information given to making apparatuses, handling activities and removing of materials. Everybody has their own particular manners to comprehend the importance of innovation as it has an extensive variety of activities and effect over the world. We utilize innovation to expand our capacities, and that makes individuals the most imperative piece of the mechanical framework.


Technology: The Change of Life

Innovation is a dynamic division as it generally continues enhancing as indicated by the need and requests for the continuing evolution. The radical change has occurred as we moved from Industrial age to Information age. Amid Industrial Age, organizations with enormous capitals just can possibly bear the cost of mechanical devices to increase upper hands. In any case, with the progression in innovation, another financial condition has made, which requires Information we are what is called "Data Age". The data age gives an immense stage to the little organizations to assemble their business with an alternate workplace in the focused markets.

Universities like Amity University, conduct Amity JEE examination every year. Application forms for Amity JEE 2018 exam are being distributed from 31st October 2017 to 31st March 2018. The examination is the best way to get admission in top 10 Amity Universities in India. The University provides the vast variety of departments using the latest technological tools for better improvements of their students. Not just in Engineering, but in Medical field also.

Talking about building the field, our organizations like Indian Institute of Technology, [IIT] gives one the best researchers around the globe. These researchers later turn into the innovators of various specialists that we use in our everyday lives. JEE-Main 2018 is the following period of the examination. The syllabus helps trying applicants in knowing the points and parts of Physics, Chemistry, and Mathematics from where they should contemplate keeping in mind the end goal to get ready for the designing passageway test. The JEE-Main 2018 Admit Card will be available 48 hours prior to the examination.

Technology is always being high in demands by the people. Scientists work hard to fulfill the needs. As the demand is increasing at a high pace, scientists are trying to their skills also.


Artificial Intelligence


Artificial Intelligence is one of the examples of technology, which is invented to make our work easy, help us with our difficult decisions and to aid us in the medical field also. But with every pro, there are always the cons. There is always a war or debate going on about Artificial Intelligence. Many questions were asked against their trust and obedience. Finally, on 25th October 2017, Sophia, an Artificial Intelligence became the first robot to get a citizenship of Saudi Arabia. "My AI is designed around human values like wisdom, kindness, and compassion," she said. When questioned about her potential for abuse, she had a quick rebuttal. "You've been reading too much Elon Musk and watching too many Hollywood movies. Don't worry, if you're nice to me I'll be nice to you." These were the words it said inside the conference hall.

As the world is succeeding by doing such inventions, the outcome is still suspicious to us. But it doesn’t mean that we can’t take advantage of that. The cons are minor but the pros are so beneficial to our world. We just need to utilize it in every way possible.


Author of This Post


Kishore Kumar is a well-known blogger and content writer. If you have any Query/complain/suggestions regarding this post, you can comment or contact to author of this post. You can always read his posts on www.getmyuni.com to know how to reach your objectives easily. Know more about Kishore Kumar Click here.
Read More »

Tuesday, 14 November 2017

Liferay DXP – Why When What Who

Liferay DXP – Why When What Who



What is Liferay DXP? or What is Java Liferay? or What is Liferay in it? or What language is Liferay written in?.


Liferay DXP – Why When What Who

In 2016 Gartner accredited Liferay as a leader in the Magic Quadrant for Horizontal Portals for the seventh year in a row based on parameters such as market understanding, sales strategy, innovation, core product and services offerings, financial health, customer experience and market responsiveness. It was the same year when Liferay introduced next level of its enterprise edition as Liferay DXP that got a warm welcome from both the developer community and the enterprise.


Why Liferay DXP


Liferay DXP is a revolutionary version of Liferay that has entitled it as a competent technology platform rather than an enterprise portal solution.

Strategically Developed Mature Product

  • Liferay DXP is a mature technology platform that has been innovated and launched after a significantly successful journey of Liferay

  • You can get developed a highly customized solution that can match with any specific, comprehensive or complex requirements along with remarkable performance

Intelligent Investment

  • Liferay DXP can be considered as an intelligent investment as it offers resilient and dynamic technology low TCO and high ROICost effective to maintain and to scale with growth and time 

  • Well-equipped open source with built-in resources, hence you don’t need to pay for additional features
  • Lower ancillary and scaling costs due to better supports to more choices for hardware and software compatibility

Trouble-free Adoption


  • Quick configuration and secured implementation with easily adaptable and reusable presentation layer

  • Optimum User Interface, familiar desktop conveniences, and easy navigations enables easy adoption of solution across the enterprise

Agility for the Future

  • As and when required either for operational excellence or for competitive advantage, it is easy to add new functionalities and tools to your existing solution



When Liferay DXP


For logical mapping between Enterprise Architecture and Information Technology strategy

  • In general, the concept of Enterprise Architecture is mainly about structuring the logic for various business processes aligned with the enterprise’s growth plan. IT strategies are developed and implemented to standardize the business processes in line with company’s operating model with minimized possibilities of risk. Liferay DXP is the right tool to create potential sync between Enterprise Architecture and Information Technology strategy of a visionary enterprise.

  • In a practical scenario, such sync is created through technology solutions that work as a digital workplace and collaboration platform across the enterprise’s internal and external business ecosystem along with providing a personalized experience to its every user. Liferay DXP empowers you to create a winning combination of an excellent user experience encompassing all modern trends of digital interactions and substantial technological capabilities for optimized business process operations

What is Liferay DXP



  • Liferay DXP is a feature-rich enhanced digital experience platform that enables the development of cost-effective integrated technology solutions including content-rich web applications and enterprise portals that are easily adaptive to mobility

  • It is an effective tool to handle digital transformation throughout the enterprise and being used by many well-known global organizations including Airbus, Allianz, Domino’s, T-Mobile, Schneider, and NASA

Who should opt for Liferay DXP


If you are on the way of manifesting an idea into innovation

  • Once the business vision is clear, the critical components of manifesting an idea into innovation are: Engaging product design in line with nature of business, flexibility, and scalability of the proposed solution, security, and great analytical capabilities, seamless integration of the most suitable technologies and distinctive user experience

  • Liferay DXP is the right technology platform for you to conceptualize an idea into a solution encompassing the latest and futuristic aspects of innovative solution 

If you are willing to simplify and drive the agility for operational excellence as well as competitive advantage

When you are in need of an automated technology solution that can be used as organizational productivity booster and enables you:

  • To furnish your employees with secured, consistency and role-based access to organizational documents and information without any geographical limitations

  • To handle Enterprise Content Management and Web Publishing smartly in line with all up to the minute trends
  • To streamline customer communications through a collaborated platform using multiple touch points

Liferay DXP enables the development of massive, complex and integrated technology applications specifically designed not only to address each of your business challenges but also act as a potential driving force for your business.


Conclusion


When it comes to the selection of right technology, analytical and fact-based approach plays a critical role in making a fruitful decision. All in all, Liferay DXP provides the practical solution that actually works. Additionally, with low TCO and adequate ROI, it is flexible enough to drive strategic growth for the future. Apart from being used and acknowledged by globally leading organizations, Liferay DXP is strongly advocated by technology experts as well due to the functional beauty and technical capabilities.


Author of This Post


Author Bio: Namee Jani is a Passionate Sr.Digital Marketing Strategist working with Azilen Technologies. She is Certified Google Adwords & Analytics and adores catching new trends and techniques prevalent in the online marketing world. Click Here for more information about Author
Read More »

Computer Programming for Beginners

Computer Programming for Beginners or computer programming course for beginners or computer programming jobs for beginners or computer programming classes for beginners or computer programming top colleges/Institution in India.


Table of Content


1. The Computer

2. What is Programming Language

3. Top College/University

4. Choosing The Programming Language

5. The Career in Computer Programming.



1. The Computer


The computer is one of the finest outcomes of technological advancement. Usually when you use a computer it direct things like, if you want to access the 'My Computer', you double-click on 'My Computer' and access the drive which you want to view but it is not that easy because such a computer is programmed to do the commanded tasks. This article is about telling the beginners about the programming and how if they are interested in it they can go for it as a full-fledged career or they can learn to programme as an interest-based learning.


Computer Programming for Beginners

2. What is Programming Language


Programming is a set of instructions which we use in programming which involves activities such as analysis, developing understanding, generating algorithms, verification of requirements of algorithms including their correctness and resources consumption, and implementation. This is commonly referred to as coding of algorithms in a target programming language. Programming is used for software development, website development, and all other functions you can think of which are conducted by a computer. All the functions in a computer are programmed to do so. The programming is a base for all the computer operations.



3. Top College/University


There are Top Engineering Colleges in India offering certified courses on software programming, software development, and information technology, visual graphics. All these are certified programs offered by these top colleges who are competing with other top colleges all around the globe. Students can also search for top MBA Colleges in Karnataka, as Karnataka is doing well in the field of engineering and emerging as one of the finest state offering technical courses,

While going for a course on programming, students should know which language they should start from but not get hung up on choosing languages. There are various languages to choose from PHP, Jquery [Website Development], Android, Python [Mobile Software Development], Java [Software Development], C language and various other languages which a beginner can choose from to learn programming.



4. Choosing The Programming Language


After deciding which programming language, then it's all about how you use it for software developments. This is what programming is all about. The programmer's job is to convert and create a problem-solution kind of algorithm as instructions for a computer such as - when you want to find out a nearby restaurant and Google maps do it easily for you, the problem and solution for that is provided by the programmer. When someone types 'nearby restaurants' on the maps it will display all the keywords matching to restaurants and which are nearby to users. That how programming works as it was set in the command how it will go about functioning.



5. The Career in Computer Programming


There are a lot of career opportunities for computer programmers because of the rapid technological advancement and students can opt for the various different fields of programming itself. There are fields such as web designing, software development, developing game and others. If programming is where your interest lies you should go for it and be updated with the new developments in that field. Passion is driving force for satisfaction in any field.



Author of This Post


Kishore Kumar is a well-known blogger and content writer. If you have any Query/complain/suggestions regarding this post, you can comment or contact to author of this post. You can always read his posts on www.getmyuni.com to know how to reach your objectives easily. Know more about Kishore Kumar Click here.
Read More »

Monday, 6 November 2017

HackerRank Solution For Day 28: RegEx, Patterns, And Intro to Databases

Problem:- hackerRank-30-Days-of-Code/Day-28-RegEx-Pattern or Hackerrank, 30 Days of Code Challenges or Hackerrank 30 days of code Java Solution: Day 28 or HackerRank - Advance Your Coding Through Problem Solving or 30 Days of Code – Day 28: RegEx, Patterns, and Intro to Databases or C Language: HackerRank Day 28 Data Types 30 Day Solution In C or Day 28: RegEx, Patterns, and Intro to Databases or The 30 Days Regex Tutorial

Task

Consider a database table, Emails, which has the attributes First Name and Email ID. Given N rows of data simulating the Emails table, print an alphabetically-ordered list of people whose email address ends in @gmail.com (RegEx Pattern)

Sample Input

6
riya riya@gmail.com
julia julia@julia.me
julia sjulia@gmail.com
julia julia@gmail.com
samantha samantha@gmail.com
ghanendra ghanendra.yadav@gmail.com


Sample Output

ghanendra
julia
julia
riya
samantha

Output Format

Print an alphabetically-ordered list of first names for every user with a Gmail account. Each name must be printed on a new line.

Explanation:- RegEx, Patterns, and Intro to Databases Solution is same as SQL Query. First, we have database table consist first name and email Now we have to print the name of the person whose email ID ends with @gmail.com. So first step is to take a regular expression in like this "regex exp(".+@gmail\\.com$");" and now with the help of sting array we will take an input Fname and Eid and compare Eid with a regular expression If Eid is matched with a regular expression then we store name of the person in a String array. Now the last step is to print the string array in order.
For better explanation let's take an example of above Sample Input, here number 6 ( total number of input ) and a first name and Email ID. As you can see the first email is riya@gmail.com this is correct so store or push into a string array, now come to second Email ID julia@julia.me as we can see there is no matching with @gmail.com than ignore this name and Email ID same for next and next to next and continue all have passed the condition. Now next step is to print the First name in ascending order.

Submit Your Solution Here:- Click Here


Solution:- Day 28: RegEx, Patterns, and Intro to Databases 

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, i;

    cin >> N;

    regex exp(".+@gmail\\.com$");

    vector<string> strarray;

    for(i = 0; i < N; i++)
{
        string Fname;

        string Eid;

        cin >> Fname >> Eid;

        if(regex_match(Eid, exp))
{
            strarray.push_back(Fname);
        }
    }

    sort(strarray.begin(), strarray.end()); 

    for(i = 0; i < strarray.size();i++) 
    { 
        cout << strarray[i] << endl; 
    }

    return 0;
}

Output:-


HackerRank solution For Day 28: RegEx, Patterns, and Intro to Databases

You May Also See


1. Day 24: More Linked Lists

2. Day 25: Running Time and Complexity

3. Day 26: Nested Logic

4. Day 27: Testing

5. Day 29: Bitwise AND
Read More »

Hospital Management System Project in java

Problem:- Hospital Management in JAVA or Hospital Management System or Hospital Management System Project in java or Hospital Management Java Project or java codes on hospital management or Hospital Management System in JAVA or Hospital Management System Project for Final Year or Hospital Management in JAVA (Computer Project)  or CSE Final Year Projects Hospital Management in JAVA or Free Download Hospital Management System Java Project With Source Code or Java Projects Hospital Management system

Explanation:- Hospital Management is very popular projects, In this project, I cover 1.DOCTOR  2. PATIENT  3.MEDICAL  4.LAB  5. FACILITY  6.STAFF tables. Now take an example of Doctor table, I already saved some doctor details, when you select option 1.Doctor than 2 option will occur and 1.new entry or 2.doctor list Here you can save the details of New Doctor like Below.

Id:-
Name:-
Specialization:-
Working Time:-
Qualification:-
Room No:-

and you can see the new updated list of the doctors and by pressing 2 you can see those details Check Below. 

2.doctor list
--------------------------------------------------------------------------------------------
id       name              specialist       timing          qualification   room no
--------------------------------------------------------------------------------------------
21      Dr.Ghanendra    ENT           10-04             MBBS, MD         17
32      Dr.Vikram          Physician    10-04             MBBS, MD         45
17      Dr.Rekha          Child            10-04             BDM                   8
33      Dr.Pramod        Artho           10-04             MBBS, MS         40
17      Dr.Yadav           Artho            08-12            MBBS                12

In Hospital Management System you can also check the patient list or you can admit new patient same as Doctor List for that you have to go the main menu and select patient than 2 option will occur 1.new entry or 2.patient list and by pressing 2 you can check the patient details. these are the list of my friend and they are not patient they are absolutely fine(Just for Fun).

2.patient list
--------------------------------------------------------------------------------
id       name       disease         sex     admit_status    age
--------------------------------------------------------------------------------
12      Pankaj    cancer          male            y               30
13      kuli          cold              male            y               23
14      Gaurav   Malaria         male            y               45
15      Ravi        sugar           male             y               25


Solution:- Hospital Management System Project in java

import java.io.*;
import java.util.*;
import java.util.Calendar;

/* Program By Ghanendra Yadav
    Visit http://www.programmingwithbasics.com/
*/

class staff
{
String sid,sname,desg,sex;
int salary;
void new_staff()
{
Scanner input=new Scanner(System.in);
System.out.print("id:-");sid=input.nextLine();
System.out.print("name:-");sname=input.nextLine();
System.out.print("desigination:-");desg=input.nextLine();
System.out.print("sex:-");sex=input.nextLine();
System.out.print("salary:-");salary=input.nextInt();
}
void staff_info()
{
System.out.println(sid+"\t"+sname+"\t"+sex+"\t"+salary);
}
}


class doctor
{
String did,dname,specilist,appoint,doc_qual;
int droom;

void new_doctor()
{
Scanner input=new Scanner(System.in);
System.out.print("id:-");did=input.nextLine();
System.out.print("name:-");dname=input.nextLine();
System.out.print("specilization:-");specilist=input.nextLine();
System.out.print("work time:-");appoint=input.nextLine();
System.out.print("qualification:-");doc_qual=input.nextLine();
System.out.print("room no.:-");droom=input.nextInt();
}
void doctor_info()
{
System.out.println(did+"\t"+dname+"  \t"+specilist+"     \t"+appoint+"    \t"+doc_qual+"       \t"+droom);

}
}


class patient
{
String pid,pname,disease,sex,admit_status;
int age;

void new_patient()
{
Scanner input=new Scanner(System.in);
System.out.print("id:-");pid=input.nextLine();
System.out.print("name:-");pname=input.nextLine();
System.out.print("disease:-");disease=input.nextLine();
System.out.print("sex:-");sex=input.nextLine();
System.out.print("admit_status:-");admit_status=input.nextLine();
System.out.print("age:-");age=input.nextInt();
}
void patient_info()
{
System.out.println(pid+"\t"+pname+" \t"+disease+"     \t"+sex+"      \t"+admit_status+"\t"+age);
}
}


class medical
{
String med_name,med_comp,exp_date;
int med_cost,count;

void new_medi()
{
Scanner input=new Scanner(System.in);
System.out.print("name:-");med_name=input.nextLine();
System.out.print("comp:-");med_comp=input.nextLine();
System.out.print("exp_date:-");exp_date=input.nextLine();
System.out.print("cost:-");med_cost=input.nextInt();
System.out.print("no of unit:-");count=input.nextInt();
}
void find_medi()
{
System.out.println(med_name+"  \t"+med_comp+"    \t"+exp_date+"     \t"+med_cost);
}
}

class lab
{
String fecility;
int lab_cost;

void new_feci()
{
Scanner input=new Scanner(System.in);
System.out.print("fecility:-");fecility=input.nextLine();
System.out.print("cost:-");lab_cost=input.nextInt();
}
void feci_list()
{
System.out.println(fecility+"\t\t"+lab_cost);
}
}


class fecility //Sorry Facility but do not change the name 
{

String fec_name;
void add_feci()
{
Scanner input=new Scanner(System.in);
System.out.print("fecility:-");fec_name=input.nextLine();

}
void show_feci()
{
System.out.println(fec_name);
}
}


public class HOSPITALMGT
{
public static void main(String args[])
{
String months[] = {
"Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec"};
Calendar calendar = Calendar.getInstance();
//System.out.println("--------------------------------------------------------------------------------");
int count1=4,count2=4,count3=4,count4=4,count5=4,count6=4;

System.out.println("--------------------------------------------------------------------------------");
System.out.println("                          ***HOSPITAL MANAGEMENT SYATEM***");
System.out.println("--------------------------------------------------------------------------------");
System.out.print("Date: "+months[calendar.get(Calendar.MONTH)]+" " + calendar.get(Calendar.DATE) + " "+calendar.get(Calendar.YEAR));
System.out.println("\t\t\t\t\t\tTime: "+calendar.get(Calendar.HOUR) + ":"+calendar.get(Calendar.MINUTE) + ":"+calendar.get(Calendar.SECOND));

doctor[] d=new doctor[25];
patient[] p=new patient[100];
lab[] l=new lab[20];
fecility[] f=new fecility[20];
medical[] m=new medical[100];
staff[] s=new staff[100];
int i;
for(i=0;i<25;i++)
d[i]=new doctor();
for(i=0;i<100;i++)
p[i]=new patient();
for(i=0;i<20;i++)
l[i]=new lab();
for(i=0;i<20;i++)
f[i]=new fecility();
for(i=0;i<100;i++)
m[i]=new medical();
for(i=0;i<100;i++)
s[i]=new staff();

d[0].did="21"; d[0].dname="Dr.Ghanendra"; d[0].specilist="ENT"; d[0].appoint="10-4"; d[0].doc_qual="mbbs,Md"; d[0].droom=17;   
d[1].did="32"; d[1].dname="Dr.Vikram"; d[1].specilist="medi."; d[1].appoint="10-4"; d[1].doc_qual="mbbs,md"; d[1].droom=45;   
d[2].did="17"; d[2].dname="Dr.Rekha"; d[2].specilist="Child spl"; d[2].appoint="10-4"; d[2].doc_qual="bdm"; d[2].droom=8;   
d[3].did="33"; d[3].dname="Dr.Pramod"; d[3].specilist="Artho"; d[3].appoint="10-4"; d[3].doc_qual="mbbs,ms"; d[3].droom=40;   

p[0].pid="12"; p[0].pname="pankaj"; p[0].disease="cancer"; p[0].sex="male"; p[0].admit_status="y"; p[0].age=30; 
p[1].pid="13"; p[1].pname="kuli"; p[1].disease="cold"; p[1].sex="male"; p[1].admit_status="y"; p[1].age=23; 
p[2].pid="14"; p[2].pname="Gaurav"; p[2].disease="maleriya"; p[2].sex="male"; p[2].admit_status="y"; p[2].age=45; 
p[3].pid="15"; p[3].pname="ravi"; p[3].disease="sugar"; p[3].sex="male"; p[3].admit_status="y"; p[3].age=25; 

m[0].med_name="corex"; m[0].med_comp="cino pvt"; m[0].exp_date="9-5-16"; m[0].med_cost=55; m[0].count=8;
m[1].med_name="nytra"; m[1].med_comp="ace pvt"; m[1].exp_date="4-4-15"; m[1].med_cost=500; m[1].count=5;
m[2].med_name="brufa"; m[2].med_comp="reckitt"; m[2].exp_date="12-7-17"; m[2].med_cost=50; m[2].count=56;
m[3].med_name="pride"; m[3].med_comp="ddf pvt"; m[3].exp_date="12-4-12"; m[3].med_cost=1100; m[3].count=100;

l[0].fecility="x-ray     "; l[0].lab_cost=800;
l[1].fecility="ct scan   "; l[1].lab_cost=1200;
l[2].fecility="or scan   "; l[2].lab_cost=500;
l[3].fecility="blood bank"; l[3].lab_cost=50;

f[0].fec_name="ambulane";
f[1].fec_name="admit fec";
f[2].fec_name="canteen";
f[3].fec_name="free camp";

s[0].sid="22"; s[0].sname="ravi"; s[0].desg="worker"; s[0].sex="male"; s[0].salary=5000;
s[1].sid="23"; s[1].sname="komal"; s[1].desg="nurse"; s[1].sex="female"; s[1].salary=2000;
s[2].sid="24"; s[2].sname="raju"; s[2].desg="worker"; s[2].sex="male"; s[2].salary=5000;
s[3].sid="25"; s[3].sname="rani"; s[3].desg="nurse"; s[3].sex="female"; s[3].salary=20000;

Scanner input=new Scanner(System.in);

int choice,j,c1,status=1,s1=1,s2=1,s3=1,s4=1,s5=1,s6=1;
while(status==1)
{
System.out.println("\n                                    MAIN MENU");
System.out.println("--------------------------------------------------------------------------------");
System.out.println("1.DOCTOR  2. PATIENT  3.MEDICAL  4.LAB  5. FACILITY  6.STAFF 7.EXIT");
System.out.println("--------------------------------------------------------------------------------");

choice=input.nextInt();
switch(choice)
{
case 1:
   {
System.out.println("--------------------------------------------------------------------------------");
   System.out.println("                      **DOCTOR SECTION**");
   System.out.println("--------------------------------------------------------------------------------");
   s1=1;
   while(s1==1)
   {
    System.out.println("1.new entry\n2.doctor list");
    c1=input.nextInt();
    switch(c1)
    {
    case 1:
      {
      d[count1].new_doctor();count1++;
      break;
      }
    case 2:
      {
      System.out.println("--------------------------------------------------------------------------------");
      System.out.println("id \t name\t specilist \t timing \t qualification \t room no");
      System.out.println("--------------------------------------------------------------------------------");
     for(j=0;j<count1;j++)
       {
       d[j].doctor_info();
       }
      break;
      }
     }
     
     System.out.println("RETURN BACK press (1/0) for more");
     s1=input.nextInt();
    }
    break;
 }
case 2:
{
System.out.println("--------------------------------------------------------------------------------");
System.out.println("                     **PATIENT SECTION**");
System.out.println("--------------------------------------------------------------------------------");
s2=1;
while(s2==1)
{
System.out.println("1.new entry\n2.patient list");
c1=input.nextInt();
switch(c1)
{
case 1:{p[count2].new_patient();count2++;break;}
case 2:
{
System.out.println("--------------------------------------------------------------------------------");
System.out.println("id \t name \t disease \t sex \t admit_status \t age");
System.out.println("--------------------------------------------------------------------------------");
for(j=0;j<count2;j++){p[j].patient_info();}break;}
}
System.out.println("RETURN BACK press (1/0) for more");
s2=input.nextInt();
}
break;
}
case 3:
{
s3=1;
System.out.println("--------------------------------------------------------------------------------");
System.out.println("                     **MEDICAL SECTION**");
System.out.println("--------------------------------------------------------------------------------");
while(s3==1)
{
System.out.println("1.new entry\n2.medicine list");
c1=input.nextInt();
switch(c1)
{
case 1:{m[count3].new_medi();count3++;break;}
case 2:
{
System.out.println("--------------------------------------------------------------------------------");
System.out.println("name \t company \t expirity date \t cost");
System.out.println("--------------------------------------------------------------------------------");
for(j=0;j<count3;j++){m[j].find_medi();}break;}
}
System.out.println("RETURN BACK press (1/0) for more");
s3=input.nextInt();
}
break;
}
case 4:
{
s4=1;
System.out.println("--------------------------------------------------------------------------------");
System.out.println("                    **LABORATRY SECTION**");
System.out.println("--------------------------------------------------------------------------------");
while(s4==1)
{
System.out.println("1.new entry \n2.lab list");
c1=input.nextInt();
switch(c1)
{
case 1:{l[count4].new_feci();count4++;break;}
case 2:
{
System.out.println("--------------------------------------------------------------------------------");
System.out.println("fecility\t\tcost");
System.out.println("--------------------------------------------------------------------------------");
for(j=0;j<count4;j++){l[j].feci_list();
}
break;
}
}
System.out.println("RETURN BACK press (1/0) for more");
s4=input.nextInt();
}
break;
}
case 5:
{
s5=1;
System.out.println("--------------------------------------------------------------------------------");
System.out.println("          **HOSPILITY FACILITY SECTION**");
System.out.println("--------------------------------------------------------------------------------");
while(s5==1)
{
System.out.println("1.new entry\n2.fecility list");
c1=input.nextInt();
switch(c1)
{
case 1:{f[count5].add_feci();count5++;break;}
case 2:{
System.out.println("--------------------------------------------------------------------------------");
System.out.println("hospility facility are:-");
System.out.println("--------------------------------------------------------------------------------");
for(j=0;j<count5;j++){f[j].show_feci();}break;}
}
System.out.println("RETURN BACK press (1/0) for more");
s5=input.nextInt();
}
break;
}
case 6:
{
s6=1;
System.out.println("--------------------------------------------------------------------------------");
System.out.println("                       **STAFF SECTION**");
System.out.println("--------------------------------------------------------------------------------");
  while(s6==1)
  {

String a="nurse",b="worker",c="security";
   System.out.println("1.new entry\n2.nurse list\n3.worker list \n4.securuty list");
   c1=input.nextInt();
   switch(c1)
   {
     case 1:{s[count6].new_staff();count6++;break;}
     case 2:
       {
System.out.println("--------------------------------------------------------------------------------");

       System.out.println("id \t name \t sex \t salary");
System.out.println("--------------------------------------------------------------------------------");
         for(j=0;j<count6;j++)
         {
         if(a.equals(s[j].desg))
            s[j].staff_info();
         }
       break;
       }
     case 3:
       {
System.out.println("--------------------------------------------------------------------------------");
       System.out.println("id \t name \t sex \t salary");
System.out.println("--------------------------------------------------------------------------------");
       for(j=0;j<count6;j++)
         {
         if(b.equals(s[j].desg))
            s[j].staff_info();
         }
       break;
       }
     case 4:
       {
System.out.println("--------------------------------------------------------------------------------");
       System.out.println("id \t name \t sex \t salary");
System.out.println("--------------------------------------------------------------------------------");
        for(j=0;j<count6;j++)
        {
        if(c.equals(s[j].desg))
        s[j].staff_info();
        }
       break;
       }
    }
   System.out.println("RETURN BACK press (1/0) for more");
   s6=input.nextInt();
   }
break;
}
case 7:
{
break;
}
default:
{
System.out.println("enter wrong choice!");
}
}
System.out.println("RETURN MAIN MENU press (1/0) for more");
status=input.nextInt();
}
}
}

Output:-

Hospital Management System Project in java

You May Also See



1. Java Program For Calculator Using AWT Controls (GUI)

2. JAVA Project SMS (School Management System) Using Multiple Classes

3. C++ Program For Student Report Card ( SRC PROJECT ) With Source Code

4. C++ Tic Tac Toe Game Project With Source Code

5. C++ Program For School Management System ( SMS Project ) With Source Code
Read More »

Saturday, 4 November 2017

An Applet Program That Print Random Dot in Java

Problem:- Write an applet program in Java that display Random dot in screen or An applet program that displays random dot or Draw Dots at Random Locations in an Applet Example or java - Drawing random points in JApplet or java - Simplest way to display a window with dots on it or arrays - dot random movement in java or Random Dots or Java Random Number Examples or A program of the applet that draws a dot at a random location in its or An Applet Program That Print Random Dot in Java or Draw Dots at Random Locations in an Applet Example.

Explanation:- This is a very interesting problem, your task is to print random dots on the screen. while you can also control the speed of dots and color of dots. Now come to point first you to copy this program and save with .java extension, now press the win+R key and enter CMD and press Enter. Now locate the program where you save it with the help of CD command ie.- "cd Desktop". If you are getting problem how to run applet program in java via command link check this How to Run Java Applets and Swing Using Command Line. Now just open and run the program and see the magic.

Now Come to technical terms of this program ie. How drawing random points in JApplet is working. So basically there are 6 steps.

1. public void init()
2. public void run()
3. Thread.sleep(1)
4. public void paint(Graphics g)
5. g.fillOval(x,y,10,10)
6. g.setColor(Color.red)


1. public void init()

public void init is used for initialization of the Thread, this is the first process.

2. public void run()

the public void run is responsible for the run the thread and catching if any exception occurs, you can put condition theirs. how many time you want to run the Loop etc.

3. Thread.sleep(Integer Value)

Thread.sleep(1000) is used for sleep The Thread means no operation will be performed for a given time, here 1000 means 1 Second and 1 means 1/1000 Second. So for a given time, no operation will be performed and the program will be Idle for a given time.

4. public void paint(Graphics g)

Performing a painting and drawing task, here color and shape decide.

5. g.fillOval(x, y, 10, 5)

This is a property of filling a color in any shape here is an X-Axis and y is a Y-Axis and 10 and 5 is the size of an Oval(Height and Width) but in Applet X-Axis is Left to Right and Y- Axis is Top to Bottom.

6. g.setColor(Color.red)

This is a property of the coloring a shape.


Solution:- Draw Dots at Random Locations in an Applet


import java.applet.Applet;
import java.awt.*;

/* Program By Ghanendra Yadav
    Visit http://www.programmingwithbasics.com/
*/
/*
        <applet code = "DRAWDOTSRANDOM" width = 600 height = 400>
        </applet>
*/
public class DRAWDOTSRANDOM extends Applet implements Runnable
{  
    Thread t;
    public void init()
{              
        t = new Thread(this);
        t.start();
    }
       
    public void run()
{   
        try
{      
            while(true)
{
                repaint();
                Thread.sleep(1);
            }
        }
        catch(Exception e)
{
        }       
    }
    public void update(Graphics g)
{
        paint(g);
    }
       
    public void paint(Graphics g)
{               
        Dimension d = getSize();
        int x = (int)(Math.random() * d.width);
        int y = (int)(Math.random() * d.height);
g.setColor(Color.red); 
        g.fillOval(x,y,10,10);          
    }

}

Output:-
Read More »