Search This Blog

Monday 25 July 2022

5. Java Program to generate Registration Number based on Year, Cycle and Serial Number.

/* 5. (2019-20 Syllabus) Assume that an examination authority conducts qualifying examination for candidates twice eachyear. First, in the month of June, second, in the month of December. Before the exam, it opens a registration process so that candidates register themselves. After the end of the registration dates, the authority consolidates the list of candidates and generates the unique register numbers. These numbers are assigned to each candidate. The format of the register numbers is as below.
Each register number should contain  exactly 10 characters. */
/*For example, if year of registration 2018, cycle 2 and there are five candidates registered then, registration numbers are: QE20182001, QE20182002, QE20182003, QE20182004, QE20182005.
The serial numbers should contain exactly 3 digits. To maintain it, prefix zeros as needed. (up to 9 serial number should be prefixed with two zeros, after 9, upto 99 it should be prefixed with single zero and after 99, no zeros). Write a Java program to generate the registration numbers as per the above requirement. */

import java.io.*;
class ProgNw5
{
    public static void main(String args[])throws IOException
    {
        String name[]=new String[50];
        String year[]=new String[50];
        String cycle[]=new String[50];
        String month;
        String count1[]=new String[50];
        System.out.println("Registration of Students for             Exams:");
        DataInputStream in= new DataInputStream(System.in);    
        System.out.println("Enter number of students");
        int n=Integer.parseInt(in.readLine());
        int count=0;
        for(int i=0;i<n;i++)
        {
         System.out.println("Enter the Name, Year and                   Month(June or December)");
            name[i]=in.readLine();
            year[i]=in.readLine();
            //cycle[i]=in.readLine();
            month=in.readLine();
 
        if(month.equals("June") || month.equals("june") ||  
              month.equals("JUNE"))
            {
                cycle[i]="1";
            }
            else
                cycle[i]="2";
            count++;
            if(count<10)
                count1[i]="00"+count;
            else
                count1[i]="0"+count;
            //System.out.println("Regno=QE"+year[0]+cycle[0]+"001");
        }
        System.out.println("Details of Students:");
        System.out.println("Name\t SerialNumber");

        for(int i=0;i<n;i++)
        {
  System.out.println(name[i]+"\\tQE"+year[i]+cycle[i]+count1[i]);
        }    }    }   

No comments :

Post a Comment

FREE Hit Counters