Suppose an organization wishes to provide a secured short messaging services to its employees, wherein the employees can send short messages (restricted to a maximum of 200 characters) to other employees within the organization. However, as these messages can contain official or confidential information, they are classified as Normal, or Official based on certain key words present in the message contents. Every message, normal or official, has certain common fields that are as follows: 1. from field that contains the id of the sender 2. to field that contains the id of the receiver 3. sendDate field that contains the sending date of the message 4. body field that contains the message body However, if the message body contains any of the words, ”business”, ”secret” or ”attachment”, then the message is classified as official and the following actions are taken  A cc field is added which is set to value ”records”.  Further, before assigning the body field with the message text, the entire string will be reversed and assigned to the body variable. You have to write a menu based program that will have the following functionalities: 1. New Message: When the user provides this option, the user will be prompted to provide the from, to and body values. In the body field, the message is completed as soon as the user presses ”Enter”. Implement this functionality by a newMessage() method that will create a new message. But remember if the message body contains the above stated keywords, then an official message has to created. However you should use the same method name newMessage() for doing the same. 2. Show Messages: If the user selects this option, prompt him to provide the from, to and sendDateFrom and sendDateTo values that denotes the range of sending dates. Search messaged with the matching fields and show the message details, i.e. all the fields of the message. If the message is an official message, then the body will contain the reverse string, you have to reverse it again before displaying it. You should use a common method named showMessage() for displaying the messages 3. Print Official Messages: If the user selects this option, prompt him to enter a particular date, print the details of all the official messages sent on that day. However, in this case you should not reverse the body, print it as it is. Note that this method is applicable only for official messag

import java.util.Scanner;

class lab

{    

 

    public static void main(String args[])

    {

       

      String from ;

      String date;

      String to;

      String body;

   

     Scanner vinnu=new Scanner(System.in);

 //   ArrayList<Employe> emp=new ArrayList<Employe>();

     Message []obj=new Message[100];

     for(int i=0;i<100;i++)

     {

        obj[i]=new Message();

     }

     while(true)

     {

             System.out.println("   1.NEW MESSAGE\n   2.SHOW MESSAGE\n   3.PRINT OFFICIAL MESSAGES    ");

           

             System.out.print("   PLEASE ENTER YOUR CHOICE  =  ");

             

               int choice;

               choice = vinnu.nextInt();

              System.out.print(" \n  ");

              switch(choice)

              {

             

                  case 1 :

                          int j=0;

                               

                                           obj[j].newMessage();

                                       

                                                       

                           

                             j++;

                      break;

                  case 2:

                      //int x=0;

                      int i = 0;

                      System.out.print(" \n  ");

                      System.out.print("ENTER FROM WHOM =   ");

                      String from1 = vinnu.nextLine();

                      vinnu.nextLine();

                      System.out.print("ENTER TO WHOM =   ");

                      String to1 = vinnu.nextLine();

                      System.out.print("ENTER FROM send from =   ");

                      int senddatefrom;

                      senddatefrom = vinnu.nextInt();

                       vinnu.nextLine();

                      System.out.print("ENTER TO  sentdateto  ");

                       int senddateto;

                         senddateto = vinnu.nextInt();

                     

                  if(from1.equals(obj[i].from)&&to1.equals(obj[i].to))

                     

                          obj[i].showMessage();

                         

                     

                     i++;

                      break;

                  case 3:

                      String date2;

                        System.out.println(" NTER THE DATE =    ");

                        date2=vinnu.next();

                              for( i=0;i<100;i++)

                                     {

                                              if( date2.equals(obj[i].date))

                                                      {

                                                          System.out.print("sss");

                                                      }

                                     }

              }

             

   

          }

    }

}

   

   

  class Employe

 {

 String name;

 }

class Message

{

   

    String from;

    String to;

    String body;

    String date;

    String business,secret,attachment,c;

    Scanner vinnu=new Scanner(System.in);

   

     void newMessage()

    {

                             

                                  System.out.print(" ENTER THE MESSAGE SENDER : ");

                                     from = vinnu.next();

                                  System.out.print("   SEND MESSAGE TO  : ");

                                     to = vinnu.next();

                                  System.out.print("   ENTER THE DATE : ");

                                     date = vinnu.next();

                                 

                                 // System.out.println ("\n ");

                               System.out.println ("   ENTER THE BODY : ");

                                      vinnu.nextLine();

                                      body =vinnu.nextLine();

                               

               

                                  StringBuilder s=new StringBuilder(body);

                                     

                                      if(body.contains("business")||body.contains("secret")||body.contains("attachment"))

                                      {

                                          System.out.println("  IT IS AN OFFICIAL MESSAGE  ");

                                                String cc="records";

                                       

                                           s=s.reverse();

                                           c=s.toString();

                                       //    System.out.println(" REVERSE   = "+c);      

                                         

                                      }

                                         

                                      else

                                      {

                                         System.out.println ("IT IS AN NORMAL MESSAGE  ");

                                      }

        }

     void showMessage()

     {

         System.out.println(" \t DETAILS OF THE MESSAGE    ");

          System.out.println("from =   "+this.from);

           System.out.println(" TO  =   "+this.to);

           System.out.println(" date  =   "+this.date);

           System.out.println(" body  =   "+this.body);

                     

                     

     }

   

   

}
Suppose an organization wishes to provide a secured short messaging services to its employees, wherein the employees can send short messages (restricted to a maximum of 200 characters) to other employees within the organization. However, as these messages can contain official or confidential information, they are classified as Normal, or Official based on certain key words present in the message contents. Every message, normal or official, has certain common fields that are as follows: 1. from field that contains the id of the sender 2. to field that contains the id of the receiver 3. sendDate field that contains the sending date of the message 4. body field that contains the message body However, if the message body contains any of the words, ”business”, ”secret” or ”attachment”, then the message is classified as official and the following actions are taken  A cc field is added which is set to value ”records”.  Further, before assigning the body field with the message text, the entire string will be reversed and assigned to the body variable. You have to write a menu based program that will have the following functionalities: 1. New Message: When the user provides this option, the user will be prompted to provide the from, to and body values. In the body field, the message is completed as soon as the user presses ”Enter”. Implement this functionality by a newMessage() method that will create a new message. But remember if the message body contains the above stated keywords, then an official message has to created. However you should use the same method name newMessage() for doing the same. 2. Show Messages: If the user selects this option, prompt him to provide the from, to and sendDateFrom and sendDateTo values that denotes the range of sending dates. Search messaged with the matching fields and show the message details, i.e. all the fields of the message. If the message is an official message, then the body will contain the reverse string, you have to reverse it again before displaying it. You should use a common method named showMessage() for displaying the messages 3. Print Official Messages: If the user selects this option, prompt him to enter a particular date, print the details of all the official messages sent on that day. However, in this case you should not reverse the body, print it as it is. Note that this method is applicable only for official messag Suppose an organization wishes to provide a secured short messaging services to its employees, wherein the employees can send short messages (restricted to a maximum of 200 characters) to other employees within the organization. However, as these messages can contain official or confidential information, they are classified as Normal, or Official based on certain key words present in the message contents. Every message, normal or official, has certain common fields that are as follows: 1.   from field that contains the id of the sender 2.  to field that contains the id of the receiver 3.  sendDate field that contains the sending date of the message 4.  body field that contains the message body However, if the message body contains any of the words, ”business”, ”secret” or ”attachment”,  then the message is classified as official and the following actions are taken   A  cc field is added which is set to value ”records”.   Further, before assigning the body field with the message text, the entire string will be reversed and assigned to the body variable. You have to write a menu based program that will have the following functionalities: 1.  New Message: When the user provides this option, the user will be prompted to provide the from, to and body values. In the body field, the message is completed as soon as the user presses ”Enter”. Implement this functionality by a newMessage() method that will create a new message. But remember if the message body contains the above stated keywords, then an official message has to created. However you should use the same  method name newMessage() for doing the same. 2.  Show Messages: If the user selects this option, prompt him to provide the from, to and sendDateFrom and sendDateTo values that denotes the range of sending dates. Search messaged with the matching fields and show the message details, i.e. all the  fields of the message. If the message is an official message, then the body will contain the reverse string, you have to reverse it again before displaying it. You should use a common method named showMessage() for displaying the messages 3.  Print Official Messages: If the user selects this option, prompt him to enter a particular date, print the details of all the official messages sent on that day. However, in this case you should not reverse the body, print it as it is. Note that this method is applicable only for official messag Reviewed by Unknown on 03:52 Rating: 5

No comments:

Powered by Blogger.