Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Pro Blog
  • Users
  • Groups
  • Unsolved
  • Solved
Collapse
Secnto AI
  1. Secnto AI
  2. Categories
  3. Virtual University
  4. CS508 - Modern Programming Languages
  5. CS508 Assignment 3 Solution and Discussion Fall 2019
CS508 Assignment No. 03
 Solution and Discussion
zaasmiZ
Topic thumbnail image
CS508 - Modern Programming Languages
CS508 GDB 1 Solution and Discussion
O
Re: CS508 GDB.1 Solution and Discussion Total Marks 5 Starting Date Monday, February 15, 2021 Closing Date Tuesday, February 16, 2021 Status Open Question Title GDB Question Description In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time. In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not: Listing 1: (anonymous method in C# to check if a student is teenager or not) delegate(Student std) { return std.Age > 12 && std.Age < 20; } While the same functionality can be achieved by using lambda as; Listing 2: (checking if a student is teenager or not using lambda in C#) std => std.Age > 12 && std.Age < 20; Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability? Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.
CS508 - Modern Programming Languages
CS508 Assignment 3 Solution and Discussion
zaasmiZ
Re: CS508 Assignment 3 Solution and Discussion Fall 2019 Assignment No. 03 Semester Spring 2020 CS508- Modern Programming Languages Total Marks: 20 Due Date: July 27, 2020 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file is corrupt. • The assignment is completely or partially copied from (other student or ditto copied from handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .rar format. Submission details Following files must be submitted in a single zip or rar file. • Code files(.java files) • A .gif file which shows working of your application (For Recording .gif a software named Screentogif is uploaded on LMS, or you can use any other gif recording tool as well) Please note if you submit doc or txt file you will be awarded 0 marks. Make sure to write your own VU ID in the assignment file(s) otherwise assignment will not be accepted. If you do not submit any of the above mentioned file 50% marks per file will be deducted. Objective The objective of this assignment is to give students an idea on how to implement Multithreading with Synchronization concepts in JAVA. Lectures Covered: This assignment covers Lecture # 27-30 Problem Statement: You are required to create a multithreaded console application in java having 4 classes which will calculate factorial of last 4 digits of your student id. These classes would be as follow: Main class Factorial Class having one method which will calculate factorial named printfactorial(). Thread1 class which extends from Thread Class Thread2 class which also extends from Thread Class Working: Store last four digits of your student ID in a two separate classes. For example, if your ID is bc123456789 then store 67 in first Thread1 Class and 89 in Thread2 Class that will be passed to Factorial class later. Thread1 class will pass 67 to the Factorial class and printfactorial() will print factorial of all the numbers from 1 to 67. Thread2 class will pass 89to the Factorial class and printfactorial() will print factorial of all the numbers from 1 to 89. You should use thread.sleep(10) after each calculation inside the loop. As you know that you cannot store and print factorial of large numbers in simple integer or long type variables, so you are required to use BigInteger to store and print very long numbers. printfactorial() method must be synchronized so that results of Thread1 is printed first then the result of Thread2 is calculated and printed. Note: Proper exception handling code must be written where required.
CS508 - Modern Programming Languages
CS508 Assignment 2 Solution and Discussion Spring 2020
zaasmiZ
Re: CS508 Assignment 2 Solution and Discussion Assignment No. 02 Semester Spring 2020 CS508- Modern Programming Languages Total Marks: 20 Due Date:12 June 2020 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file is corrupt. • The assignment is completely or partially copied from (other student or ditto copied from handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .rar format. Submission details Following files must be submitted in a single zip or rar file. • Code file(.adb file) • A .gif file which shows working of your application (For Recording .gif a software named Screentogif is uploaded on LMS, or you can use any other gif recording tool as well) Please note if you submit doc or txt file you will be awarded 0 marks. Make sure to write your own VU ID in the assignment file(s) otherwise assignment will not be accepted. If you do not submit any of the above mentioned file 50% marks per file will be deducted. Objective The objective of this assignment is to give students idea on how to implement object oriented concepts in ADA. Lectures Covered: This assignment covers Lecture # 13 – 17 You will develop Ada console application in GNAT IDE. You can also use any online compiler to compile Ada. Problem Statement: As you know that we cannot implement inheritance in Ada directly as there is no concept of class in Ada, we need to use a mix of tagged types and packages. You are required to create a tagged type as person and then another as men, the tagged type men will inherit from person type. The person type has following attributes: • Name: String • Age: Integer • Gender: Boolean Functions: And also a function named print() [This function will print all three attributes of type person] The tagged type men have following attributes • Height: float • ID: String Functions: This type will also have one function named print() which must print all the attributes of type men and person as well. When application starts an instance of type men will be created and detail of men will be taken from user input and assigned to men type object after that the added details will be printed on the console screen.
CS508 - Modern Programming Languages
How to Run A Simple SNOBOL Program
zareenZ
Download the Compiler from Link Extract the file snobol4.exe (e.g. I have extracted the file in desktop folder in my Z drive) Download the sample code file from TEST.SNO VU-LMS (It is simple text file you can view and edit in notepad)TEST.sno Put the TEST.SNO in the same directory where snobol4.exe is Enter the following command SNOBOL4 TEST /q; you will see the output of the program if there is no error. [image: KYnh1pL.png]
CS508 - Modern Programming Languages
CS508 Assignment 1
 Solution and Discussion
J
Re: CS508 Assignment No. 01 Solution and Discussion Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: The assignment is submitted after due date. The submitted assignment does not open or file is corrupt. The assignment is completely or partially copied from (other student or ditto copied from handouts or internet). Student ID is not mentioned in the assignment File or name of file is other than student ID. The assignment is not submitted in .rar format. Submission details Following files must be submitted in a single zip or rar file. Code file(.sno file) A .gif file which shows working of your application (For Recording .gif a software named Screentogif is uploaded on LMS, or you can use any other gif recording tool as well) Please note if you submit doc or txt file you will be awarded 0 marks. Make sure to write your own VU ID in the assignment file(s) otherwise assignment will not be accepted. If you do not submit any of the above mentioned file 50% marks per file will be deducted. Objective The objective of this assignment is to give hands on practice on Snobol programming language. Lectures Covered: This assignment covers Lecture # 1 - 9 You are required to create a Snobol Console Program. You will use Snobol4 Compiler to compile Snobol code, if you are using a 64-bit operating system then Snobol4 compiler will not work directly you need to use DOSBox to run the compiler and compiler code.(Tutorial document has already been uploaded on Lms on how to compile code in DOSBox). Please note that you cannot use any online compiler. Problem Statement: You need to create a console application in Snobol which will execute nested loop based on your student id. Last four digits of your id will be used in both loops. For example, if your id is bc120401122 then outer loop will execute 11 times and inner loop will execute 22 times. First print your id on top of the console screen. Then inside both loops print no of times the loop has executed. You can hardcode your id in your code or take input from user. Make sure to write your id on top of the program otherwise your assignment will not be accepted.
CS508 - Modern Programming Languages
Compare both virtual machines to check which one is better than other, write at least two valid reasons in either case to support your answer.
zareenZ
Re: CS508 GDB.1 Solution and Discussion Question: As you know C# and JAVA both are virtual machine based languages, Java’s virtual machine name is Java Virtual Machine (JVM) and C#.NET names it as Common Language Runtime (CLR). Compare both virtual machines to check which one is better than other, write at least two valid reasons in either case to support your answer. Please share idea solution.
CS508 - Modern Programming Languages
CS508 Quiz 2 Solution and Discussion
zareenZ
Quiz No 2 Total Questions : 10 Please read the following instructions carefully! Quiz will be based upon Multiple Choice Questions (MCQs). You have to attempt the quiz online. You can start attempting the quiz any time within given date(s) of a particular subject by clicking the link for Quiz in VULMS. Each question has a fixed time of 90 seconds. So you have to save your answer before 90 seconds. But due to unstable internet speeds, it is recommended that you should save your answer within 60 seconds. While attempting a question, keep an eye on the remaining time. Attempting quiz is unidirectional. Once you move forward to the next question, you can not go back to the previous one. Therefore before moving to the next question, make sure that you have selected the best option. DO NOT press Back Button / Backspace Button while attempting a question, otherwise you will lose that question. DO NOT refresh the page unnecessarily, specially when following messages appear Saving... Question Timeout: Now loading next question... Javascript MUST be enabled in your browser; otherwise you will not be able to attempt the quiz. If for any reason, you lose access to internet (like power failure or disconnection of internet), you will be able to attempt the quiz again from the question next to the last shown question. But remember that you have to complete the quiz before expiry of the deadline. If any student failed to attempt the quiz in given time then no re-take or offline quiz will be held.
CS508 - Modern Programming Languages
CS508 Quiz 3 Solution and Discussion
zareenZ
Quiz No 3 Total Questions : 10 Please read the following instructions carefully! Quiz will be based upon Multiple Choice Questions (MCQs). You have to attempt the quiz online. You can start attempting the quiz any time within given date(s) of a particular subject by clicking the link for Quiz in VULMS. Each question has a fixed time of 90 seconds. So you have to save your answer before 90 seconds. But due to unstable internet speeds, it is recommended that you should save your answer within 60 seconds. While attempting a question, keep an eye on the remaining time. Attempting quiz is unidirectional. Once you move forward to the next question, you can not go back to the previous one. Therefore before moving to the next question, make sure that you have selected the best option. DO NOT press Back Button / Backspace Button while attempting a question, otherwise you will lose that question. DO NOT refresh the page unnecessarily, specially when following messages appear Saving… Question Timeout: Now loading next question… Javascript MUST be enabled in your browser; otherwise you will not be able to attempt the quiz. If for any reason, you lose access to internet (like power failure or disconnection of internet), you will be able to attempt the quiz again from the question next to the last shown question. But remember that you have to complete the quiz before expiry of the deadline. If any student failed to attempt the quiz in given time then no re-take or offline quiz will be held. Start Quiz
CS508 - Modern Programming Languages
CS508 Assignment 3 Solution and Discussion Fall 2019
zareenZ
Assignment No. 03 Semester Fall 2019 CS508 - Modern Programming Languages Total Marks: 20 Due Date:16 January 2020 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file is corrupt. • The assignment is completely or partially copied from (other student, handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .rar format. Submission details Following Files Must be submitted in a single .zip or .rar file. • Code file(s) .java file only • A .gif file which shows working of your Application (For Recording .gif a software named Screentogif is uploaded on LMS, or you can use any other gif recording tool as well) You are not required to submit the complete project, only copy these files from project folder. Please note if you submit doc or txt file you will be awarded 0 marks. Make sure to write your own VU ID in the assignment file(s) otherwise assignment will not be accepted. If you do not submit any of the above mentioned file 50% marks per file will be deducted. Objective The objective of this assignment is to give hands on practice on Java programming language. Lectures Covered: This assignment covers Lecture # 27 – 31 Problem Statement: You are required to create a multithreaded java console application which will read a text file and write processed output in another text file. • The program will be able to read the text file provided named input.txt using a separate thread. • Calculate the number of characters in the file as per your student id. • Last number of your student id is the character your program will calculate from the given list below. Last Number in ID Character to calculate Last Number in ID Character to calculate 0 ! 5 & 1 @ 6 ( 2 # 7 ) 3 $ 8 _(Underscore) 4 % 9 = • Output the result on the screen. • Create a new thread which will create an output file and store the result in that file. Output.gif has been attached with this Assignment file please observe this file carefully your program’s output must be like this output file. Assignment No 3.docx [image: ky8CGqy.gif] inputFile.txt
CS508 - Modern Programming Languages
CS508 Quiz No. 1 Solution and Discussion
zareenZ
Opening Dec 06, 2019 Closing Dec 08, 2019
CS508 - Modern Programming Languages
CS508 Quiz 1 Solution and Discussion Fall 2019
zareenZ
Re: CS508 Quiz No. 1 Solution and Discussion
CS508 - Modern Programming Languages
CS508 Assignment 2 Solution and Discussion
zareenZ
Assignment No. 02 Semester Fall 2019 CS508- Modern Programming Languages Total Marks: 20 Due Date:29 November 2019 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file is corrupt. • The assignment is completely or partially copied from (other student or ditto copied from handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .rar format. Submission details Following files must be submitted in a single zip or rar file. • Code file(s) • A .gif file which shows working of your application (For Recording .gif a software named Screentogif is uploaded on LMS, or you can use any other gif recording tool as well) You are not required to submit the complete project, only copy these files from project folder. Please note if you submit doc or txt file you will be awarded 0 marks. Make sure to write your own VU ID in the assignment file(s) otherwise assignment will not be accepted. If you do not submit any of the above mentioned file 50% marks per file will be deducted. Objective The objective of this assignment is to give hands on practice on Ada programming language. Lectures Covered: This assignment covers Lecture # 13 – 15 Output.gif has been attached with this Assignment file please observe this file carefully your program’s output must be like this output file. You are required to create an Ada Console Program using GNAT. Problem Statement: Create an Ada program which will read a text file and print all the data on the console. • Create a text file named as StudentID.txt. • Add Name, Student ID and semester in the text file. • The program will print all the data line by line on the console. • If the file is not found then appropriate error must be printed. • If the file is found but no data exist inside the file then “no data inside file” must be printed. Make sure to write your id on top of the program otherwise your assignment will not be accepted. [image: Cnvg9D9.gif]
CS508 - Modern Programming Languages
CS508 Assignment No. 01
 Solution and Discussion
zareenZ
Topic thumbnail image
CS508 - Modern Programming Languages
CS508 GDB.1 Solution and Discussion
zaasmiZ
GDB No 1…
CS508 - Modern Programming Languages
CS508 Quiz No. 2 Solution and Discussion
zaasmiZ
Please read the following instructions carefully! Quiz will be based upon Multiple Choice Questions (MCQs). You have to attempt the quiz online. You can start attempting the quiz any time within given date(s) of a particular subject by clicking the link for Quiz in VULMS. Each question has a fixed time of 90 seconds. So you have to save your answer before 90 seconds. But due to unstable internet speeds, it is recommended that you should save your answer within 60 seconds. While attempting a question, keep an eye on the remaining time. Attempting quiz is unidirectional. Once you move forward to the next question, you can not go back to the previous one. Therefore before moving to the next question, make sure that you have selected the best option. DO NOT press Back Button / Backspace Button while attempting a question, otherwise you will lose that question. DO NOT refresh the page unnecessarily, specially when following messages appear Saving… Question Timeout: Now loading next question… Javascript MUST be enabled in your browser; otherwise you will not be able to attempt the quiz. If for any reason, you lose access to internet (like power failure or disconnection of internet), you will be able to attempt the quiz again from the question next to the last shown question. But remember that you have to complete the quiz before expiry of the deadline. If any student failed to attempt the quiz in given time then no re-take or offline quiz will be held.
CS508 - Modern Programming Languages
CS508 Quiz No. 1 Solution and Discussion
M
Please share your current Quiz.
CS508 - Modern Programming Languages
Please share mid term past papers
zaasmiZ
@administrators
CS508 - Modern Programming Languages
CS508 Assignment No. 02
 Solution and Discussion
zaasmiZ
Topic thumbnail image
CS508 - Modern Programming Languages
CS508 Assignment No. 01
 Solution and Discussion
zaasmiZ
![0_1557830172549_9cdfaa7d-59f6-4280-a45e-0ed473bde543-image.png](Uploading 100%) Assignment No. 01
Semester Spring 2019 CS508- Modern Programming Languages Total Marks: 20 Due Date: May 14, 2019 Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: • The assignment is submitted after due date. • The submitted assignment does not open or file is corrupt. • The assignment is completely or partially copied from (other student or ditto copied from handouts or internet). • Student ID is not mentioned in the assignment File or name of file is other than student ID. • The assignment is not submitted in .doc or .docx format. Uploading instructions Your submission must include: • Assignment should be in .doc or .docx format. • Save your assignment with your ID (e.g. bx180200786.doc). Assignment submission through email is NOT acceptable Objective The objective of this assignment is to learn how we can evaluate different programming languages based on syntax. Note: Your answer must follow the below given specifications. • Font style: “Times New Roman” • Font color: “Black” • Font size: “12” • Bold for heading only. • Font in Italic is not allowed at all. • Your answer should be precise and to the point, avoid irrelevant detail. Lectures Covered: This assignment covers Lecture # 01 – 07 Deadline Your assignment must be uploaded/submitted at or before May 14, 2019. Q1.(8 Marks) SR No Language Name For loop Syntax 1 JAVA for(int i=1;i<11;i++){ System.out.println(i); } 2 Python for x in range(1,11): print(x) 3 Kotlin for (i in 1..10) { println(i) } 4 Swift for i in 1...10 { print(i) } Given below is for loop syntax to ‘print 1 to 10 numbers’ in 4 different Programming languages: You are required to calculate points of each language on the basis of following aspects: Readability Reliability Cost/Programming effort You have total 30 points for each language.10 points for each aspect based on your opinion. Scale: 1 point lowest and 10 highest Q2.(12 Marks): Now explain each point according to winning language in each category for example if python has higher points in Readability then explain why this language has higher points in this section as compared to other languages given above. If there is a tie in 2 languages in the same category then explain both. Note: Only consider the code of each language which is written above while calculating the points.
CS508 - Modern Programming Languages

CS508 Assignment 3 Solution and Discussion Fall 2019

Scheduled Pinned Locked Moved CS508 - Modern Programming Languages
cs508assignment 3solutiondiscussionfall 2019
6 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • zareenZ Offline
    zareenZ Offline
    zareen
    Cyberian's Gold
    wrote on last edited by zareen
    #1

    Assignment No. 03
    Semester Fall 2019
    CS508 - Modern Programming Languages
    Total Marks: 20

    Due Date:16 January 2020
    Instructions
    Please read the following instructions carefully before solving & submitting assignment:
    It should be clear that your assignment will not get any credit if:
    • The assignment is submitted after due date.
    • The submitted assignment does not open or file is corrupt.
    • The assignment is completely or partially copied from (other student, handouts or internet).
    • Student ID is not mentioned in the assignment File or name of file is other than student ID.
    • The assignment is not submitted in .rar format.

    Submission details
    Following Files Must be submitted in a single .zip or .rar file.
    • Code file(s) .java file only
    • A .gif file which shows working of your Application (For Recording .gif a software named Screentogif is uploaded on LMS, or you can use any other gif recording tool as well)
    You are not required to submit the complete project, only copy these files from project folder. Please note if you submit doc or txt file you will be awarded 0 marks. Make sure to write your own VU ID in the assignment file(s) otherwise assignment will not be accepted.
    If you do not submit any of the above mentioned file 50% marks per file will be deducted.
    Objective
    The objective of this assignment is to give hands on practice on Java programming language.

    Lectures Covered: This assignment covers Lecture # 27 – 31

    Problem Statement:

    You are required to create a multithreaded java console application which will read a text file and write processed output in another text file.
    • The program will be able to read the text file provided named input.txt using a separate thread.
    • Calculate the number of characters in the file as per your student id.
    • Last number of your student id is the character your program will calculate from the given list below.

    Last Number in ID Character to calculate Last Number in ID Character to calculate
    0 ! 5 &
    1 @ 6 (
    2 # 7 )
    3 $ 8 _(Underscore)
    4 % 9 =

    • Output the result on the screen.
    • Create a new thread which will create an output file and store the result in that file.

    Output.gif has been attached with this Assignment file please observe this file carefully your program’s output must be like this output file.

    Assignment No 3.docx
    output.gif
    inputFile.txt

    Discussion is right way to get Solution of the every assignment, Quiz and GDB.
    We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
    Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
    %(red)[NOTE: Don't copy or replicating idea solutions.]
    Quiz Copy Solution
    Mid and Final Past Papers
    Live Chat

    1 Reply Last reply
    0
    • zareenZ Offline
      zareenZ Offline
      zareen
      Cyberian's Gold
      wrote on last edited by
      #2

      https://youtu.be/cBSNINNNru0

      Discussion is right way to get Solution of the every assignment, Quiz and GDB.
      We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
      Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
      %(red)[NOTE: Don't copy or replicating idea solutions.]
      Quiz Copy Solution
      Mid and Final Past Papers
      Live Chat

      1 Reply Last reply
      0
      • zareenZ Offline
        zareenZ Offline
        zareen
        Cyberian's Gold
        wrote on last edited by
        #3

        https://youtu.be/zeAwdRvkfqI

        Discussion is right way to get Solution of the every assignment, Quiz and GDB.
        We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
        Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
        %(red)[NOTE: Don't copy or replicating idea solutions.]
        Quiz Copy Solution
        Mid and Final Past Papers
        Live Chat

        1 Reply Last reply
        0
        • zareenZ Offline
          zareenZ Offline
          zareen
          Cyberian's Gold
          wrote on last edited by
          #4

          Error: Could not find or load main class Cs508bs0000000.Cs508bs0000000

          Discussion is right way to get Solution of the every assignment, Quiz and GDB.
          We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
          Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
          %(red)[NOTE: Don't copy or replicating idea solutions.]
          Quiz Copy Solution
          Mid and Final Past Papers
          Live Chat

          1 Reply Last reply
          0
          • zareenZ Offline
            zareenZ Offline
            zareen
            Cyberian's Gold
            wrote on last edited by
            #5

            launcher.java Code

            /*
             * To change this license header, choose License Headers in Project Properties.
             * To change this template file, choose Tools | Templates
             * and open the template in the editor.
             */
            package launcher;
            
            /**
             *
             * @author Accounts
             */
            import java.util.concurrent.ArrayBlockingQueue;
            import java.util.concurrent.BlockingQueue;
            
            
            public class Launcher {
            
              public static void main(String[] args) {
            
                BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(1024);
            
                ReaderThread reader = new ReaderThread(queue);
                WriterThread writer = new WriterThread(queue);
            
                System.out.println("My ID is BS00000000 and special character to read is 'B'");
                new Thread(reader).start();
                new Thread(writer).start();    
                
                
                }
            
             } 
            
            

            ReaderThread.java Class code

            /*
             * To change this license header, choose License Headers in Project Properties.
             * To change this template file, choose Tools | Templates
             * and open the template in the editor.
             */
            package launcher;
            
            /**
             *
             * @author Accounts
             */
            import java.io.BufferedReader;
            import java.io.File;
            import java.io.FileNotFoundException;
            import java.io.FileReader;
            import java.io.IOException;
            import java.util.concurrent.BlockingQueue;
            
            public class ReaderThread implements Runnable{
            
              protected BlockingQueue<Integer> blockingQueue ;
            
              public ReaderThread(BlockingQueue<Integer> blockingQueue){
                this.blockingQueue = blockingQueue;     
              }
            
              @Override
              public void run() {
                  
                  System.out.println("Reader Thread is Started");
                  
                BufferedReader br = null;
                 try {
                        br = new BufferedReader(new FileReader(new File("./inputFile.txt")));
                        int buffer =0;
                        char match = 'B';
                        
                        while((buffer=br.read())!= -1){
                            
                            if ((char)buffer == match){
                            blockingQueue.put(buffer);
                            }
                           
                        }
                        
                        blockingQueue.put(0);  //When end of file has been reached
                         System.out.println("Reader Thread ended");
                    } catch (FileNotFoundException e) {
            
                        e.printStackTrace();
                    } catch (IOException e) {
            
                        e.printStackTrace();
                    } catch(InterruptedException e){
            
                    }finally{
                        try {
                            br.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
            
            
              }
            
            
            
            }
            
            

            WriterThread.java class code

            
            /*
             * To change this license header, choose License Headers in Project Properties.
             * To change this template file, choose Tools | Templates
             * and open the template in the editor.
             */
            package launcher;
            
            /**
             *
             * @author Accounts
             */
            
            import java.io.File;
            import java.io.FileNotFoundException;
            import java.io.PrintWriter;
            import java.util.concurrent.BlockingQueue;
            
            public class WriterThread implements Runnable{
            
              protected BlockingQueue<Integer> blockingQueue;
            
              public WriterThread(BlockingQueue<Integer> blockingQueue){
                this.blockingQueue = blockingQueue;     
              }
            
              @Override
              public void run() {
                  
                  System.out.println("Writer Thread is Started");
                  
                PrintWriter writer = null;
                char match;
                int no = 0;
                try {
                    writer = new PrintWriter(new File("outputFile.txt"));
            
                    while(true){
                        int buffer = blockingQueue.take();
                        
                        match = (char)buffer;
                        no++;
                        
                        if(buffer == (0)){ 
                            break;
                        }
                        
                        writer.println(no);
                        System.out.println("'"+match+"'" + " Found so Far :" + no);
                        
                    }               
                    System.out.println("Writer Thread ended");
                    System.out.println("Total number of Special character "+"'Blue'"+" in the file are :"+ (no-1));
                } catch (FileNotFoundException e) {
            
                    e.printStackTrace();
                } catch(InterruptedException e){
            
                }finally{
                    writer.close();
                } 
            
              }
            
            
            }
            
            

            Discussion is right way to get Solution of the every assignment, Quiz and GDB.
            We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
            Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
            %(red)[NOTE: Don't copy or replicating idea solutions.]
            Quiz Copy Solution
            Mid and Final Past Papers
            Live Chat

            1 Reply Last reply
            0
            • zareenZ Offline
              zareenZ Offline
              zareen
              Cyberian's Gold
              wrote on last edited by
              #6

              https://www.youtube.com/watch?v=j4mJTG4sWiU

              Discussion is right way to get Solution of the every assignment, Quiz and GDB.
              We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
              Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
              %(red)[NOTE: Don't copy or replicating idea solutions.]
              Quiz Copy Solution
              Mid and Final Past Papers
              Live Chat

              1 Reply Last reply
              0

              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              How to Build a $1,000/Month PAK VS BAN Live Live Cricket Streaming
              File Sharing
              Earn with File Sharing

              1

              Online

              3.0k

              Users

              2.8k

              Topics

              8.2k

              Posts
              solution
              1235
              discussion
              1195
              fall 2019
              813
              assignment 1
              428
              assignment 2
              294
              spring 2020
              265
              gdb 1
              238
              assignment 3
              79
              • PM. IMRAN KHAN
                undefined
                4
                1
                4.0k

              • Are the vaccines halal or not?
                undefined
                4
                1
                3.8k

              • All Subjects MidTerm and Final Term Solved Paper Links Attached Please check moaaz past papers
                zaasmiZ
                zaasmi
                3
                26
                75.1k

              • CS614 GDB Solution and Discussion
                M
                moaaz
                3
                3
                8.1k

              • How can I receive Reputation earning from Cyberian? 100% Discount on Fee
                Y
                ygytyh
                3
                28
                23.9k
              | |
              Copyright © 2010-26 RUP Technologies LLC. USA | Contributors
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Pro Blog
              • Users
              • Groups
              • Unsolved
              • Solved