SlideShare a Scribd company logo
1 of 4
Download to read offline
PFA JAVA program:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Bus {
static int[] applyPulse(String registers, String pulses)
{
int[] register=new int[4];
int[] pulse=new int[3];
int i=0;
StringTokenizer st = new StringTokenizer(registers," ");
while (st.hasMoreElements()) {
register[i++]=Integer.parseInt(st.nextElement().toString());
}
i=0;
st = new StringTokenizer(pulses," ");
while (st.hasMoreElements()) {
pulse[i++]=Integer.parseInt(st.nextElement().toString());
}
//Now ewe have, register [0] is A, register [1] is AB,register [3] is C and register [4] is D
if(pulse[0]==1) // if L=1
{
register[1]=register[0];
register[2]=register[0];
}
if(pulse[0]==1) // if M=1
{
register[0]=register[3];
}
if(pulse[0]==1) // if N=1
{
register[1]=register[2];
register[3]=register[2];
}
return register;
}
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter initial values of four regisers A B C D seperated by spaces");
String registers=sc.nextLine();
System.out.println("Ener value of Clock Pulse L M N seperated by spaces");
String pulses=sc.nextLine();
System.out.println("Values of registers A B C D respectively after applying pulse:");
int[] arr=applyPulse(registers,pulses);
for(int i=0;i<4;i++)
{
System.out.print(arr[i]+" ");
}
}
}
Solution
PFA JAVA program:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Bus {
static int[] applyPulse(String registers, String pulses)
{
int[] register=new int[4];
int[] pulse=new int[3];
int i=0;
StringTokenizer st = new StringTokenizer(registers," ");
while (st.hasMoreElements()) {
register[i++]=Integer.parseInt(st.nextElement().toString());
}
i=0;
st = new StringTokenizer(pulses," ");
while (st.hasMoreElements()) {
pulse[i++]=Integer.parseInt(st.nextElement().toString());
}
//Now ewe have, register [0] is A, register [1] is AB,register [3] is C and register [4] is D
if(pulse[0]==1) // if L=1
{
register[1]=register[0];
register[2]=register[0];
}
if(pulse[0]==1) // if M=1
{
register[0]=register[3];
}
if(pulse[0]==1) // if N=1
{
register[1]=register[2];
register[3]=register[2];
}
return register;
}
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter initial values of four regisers A B C D seperated by spaces");
String registers=sc.nextLine();
System.out.println("Ener value of Clock Pulse L M N seperated by spaces");
String pulses=sc.nextLine();
System.out.println("Values of registers A B C D respectively after applying pulse:");
int[] arr=applyPulse(registers,pulses);
for(int i=0;i<4;i++)
{
System.out.print(arr[i]+" ");
}
}
}

More Related Content

Similar to PFA JAVA programimport java.io.; import java.util.; import .pdf

import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfshettysachin2005
 
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdfInsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdfinfo54093
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3sotlsoc
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfmanojmozy
 
UserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdfUserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdfadityknits
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
Write the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfWrite the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfarihanthtoysandgifts
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2YOGESH SINGH
 
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfanujsharmaanuj14
 
Fee managment system
Fee managment systemFee managment system
Fee managment systemfairy9912
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIjagriti srivastava
 
this is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docxthis is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docxabhi353063
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfoptokunal1
 

Similar to PFA JAVA programimport java.io.; import java.util.; import .pdf (20)

import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
 
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdfInsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
 
Array list
Array listArray list
Array list
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
 
Java programs
Java programsJava programs
Java programs
 
UserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdfUserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdf
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Write the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfWrite the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdf
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
 
Java Week4(C) Notepad
Java Week4(C)   NotepadJava Week4(C)   Notepad
Java Week4(C) Notepad
 
Fee managment system
Fee managment systemFee managment system
Fee managment system
 
DSA - Array.pptx
DSA - Array.pptxDSA - Array.pptx
DSA - Array.pptx
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
this is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docxthis is the code using array i want with stack or linked list  or .docx
this is the code using array i want with stack or linked list  or .docx
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 

More from sudheerforce

the bond between Si and O .pdf
                     the bond between Si and O                        .pdf                     the bond between Si and O                        .pdf
the bond between Si and O .pdfsudheerforce
 
Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdf
                     Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdf                     Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdf
Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdfsudheerforce
 
step 1 Br2 under UV light step 2 NMe3 Solu.pdf
                     step 1 Br2 under UV light step 2 NMe3  Solu.pdf                     step 1 Br2 under UV light step 2 NMe3  Solu.pdf
step 1 Br2 under UV light step 2 NMe3 Solu.pdfsudheerforce
 
Since column chromatography substances are separa.pdf
                     Since column chromatography substances are separa.pdf                     Since column chromatography substances are separa.pdf
Since column chromatography substances are separa.pdfsudheerforce
 
Oh group is removed by Br yes ther can be two ty.pdf
                     Oh group is removed by Br  yes ther can be two ty.pdf                     Oh group is removed by Br  yes ther can be two ty.pdf
Oh group is removed by Br yes ther can be two ty.pdfsudheerforce
 
Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdf
                     Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdf                     Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdf
Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdfsudheerforce
 
Is this a reduction oxidation reaction If so, wh.pdf
                     Is this a reduction oxidation reaction If so, wh.pdf                     Is this a reduction oxidation reaction If so, wh.pdf
Is this a reduction oxidation reaction If so, wh.pdfsudheerforce
 
HNO3========= H+ (aq) + NO3-(aq) [H+] = 0.0578 .pdf
                     HNO3========= H+ (aq) + NO3-(aq)  [H+] = 0.0578 .pdf                     HNO3========= H+ (aq) + NO3-(aq)  [H+] = 0.0578 .pdf
HNO3========= H+ (aq) + NO3-(aq) [H+] = 0.0578 .pdfsudheerforce
 
Valley fever is the initial form of coccidioidomycosis infection. Th.pdf
Valley fever is the initial form of coccidioidomycosis infection. Th.pdfValley fever is the initial form of coccidioidomycosis infection. Th.pdf
Valley fever is the initial form of coccidioidomycosis infection. Th.pdfsudheerforce
 
Yes,The interthalamic adhesion (also known as the mass intermedia or.pdf
Yes,The interthalamic adhesion (also known as the mass intermedia or.pdfYes,The interthalamic adhesion (also known as the mass intermedia or.pdf
Yes,The interthalamic adhesion (also known as the mass intermedia or.pdfsudheerforce
 
Think of the X and Y as totally different events. The expected value.pdf
Think of the X and Y as totally different events. The expected value.pdfThink of the X and Y as totally different events. The expected value.pdf
Think of the X and Y as totally different events. The expected value.pdfsudheerforce
 
There are two source terms in Maxwell’s equations, the static charge.pdf
There are two source terms in Maxwell’s equations, the static charge.pdfThere are two source terms in Maxwell’s equations, the static charge.pdf
There are two source terms in Maxwell’s equations, the static charge.pdfsudheerforce
 
The xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdf
The xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdfThe xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdf
The xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdfsudheerforce
 
The strengths of the Indian Parliamentary System of governanace1..pdf
The strengths of the Indian Parliamentary System of governanace1..pdfThe strengths of the Indian Parliamentary System of governanace1..pdf
The strengths of the Indian Parliamentary System of governanace1..pdfsudheerforce
 
Pulse code modulationPulse code modulation is a digital sign of a.pdf
Pulse code modulationPulse code modulation is a digital sign of a.pdfPulse code modulationPulse code modulation is a digital sign of a.pdf
Pulse code modulationPulse code modulation is a digital sign of a.pdfsudheerforce
 
D) four s bonds Pi bonds are double bonds as carb.pdf
                     D) four s bonds Pi bonds are double bonds as carb.pdf                     D) four s bonds Pi bonds are double bonds as carb.pdf
D) four s bonds Pi bonds are double bonds as carb.pdfsudheerforce
 
out of Africa hypothesis out of Africa hypothesis is about .pdf
out of Africa hypothesis out of Africa hypothesis is about .pdfout of Africa hypothesis out of Africa hypothesis is about .pdf
out of Africa hypothesis out of Africa hypothesis is about .pdfsudheerforce
 
Leukocytes or WBC They are of two typesGranulocytes Neutrophils.pdf
Leukocytes or WBC They are of two typesGranulocytes Neutrophils.pdfLeukocytes or WBC They are of two typesGranulocytes Neutrophils.pdf
Leukocytes or WBC They are of two typesGranulocytes Neutrophils.pdfsudheerforce
 
In User Interface, Menu Architecture contains the following types.pdf
In User Interface, Menu Architecture contains the following types.pdfIn User Interface, Menu Architecture contains the following types.pdf
In User Interface, Menu Architecture contains the following types.pdfsudheerforce
 

More from sudheerforce (20)

the bond between Si and O .pdf
                     the bond between Si and O                        .pdf                     the bond between Si and O                        .pdf
the bond between Si and O .pdf
 
Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdf
                     Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdf                     Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdf
Step1 Equivalents of NaOH= .1146 x[19.25-.55]x10^.pdf
 
step 1 Br2 under UV light step 2 NMe3 Solu.pdf
                     step 1 Br2 under UV light step 2 NMe3  Solu.pdf                     step 1 Br2 under UV light step 2 NMe3  Solu.pdf
step 1 Br2 under UV light step 2 NMe3 Solu.pdf
 
Since column chromatography substances are separa.pdf
                     Since column chromatography substances are separa.pdf                     Since column chromatography substances are separa.pdf
Since column chromatography substances are separa.pdf
 
Option III .pdf
                     Option III                                      .pdf                     Option III                                      .pdf
Option III .pdf
 
Oh group is removed by Br yes ther can be two ty.pdf
                     Oh group is removed by Br  yes ther can be two ty.pdf                     Oh group is removed by Br  yes ther can be two ty.pdf
Oh group is removed by Br yes ther can be two ty.pdf
 
Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdf
                     Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdf                     Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdf
Moles of Na2O2 = 2578=0.32 Moles of H2O = 12.11.pdf
 
Is this a reduction oxidation reaction If so, wh.pdf
                     Is this a reduction oxidation reaction If so, wh.pdf                     Is this a reduction oxidation reaction If so, wh.pdf
Is this a reduction oxidation reaction If so, wh.pdf
 
HNO3========= H+ (aq) + NO3-(aq) [H+] = 0.0578 .pdf
                     HNO3========= H+ (aq) + NO3-(aq)  [H+] = 0.0578 .pdf                     HNO3========= H+ (aq) + NO3-(aq)  [H+] = 0.0578 .pdf
HNO3========= H+ (aq) + NO3-(aq) [H+] = 0.0578 .pdf
 
Valley fever is the initial form of coccidioidomycosis infection. Th.pdf
Valley fever is the initial form of coccidioidomycosis infection. Th.pdfValley fever is the initial form of coccidioidomycosis infection. Th.pdf
Valley fever is the initial form of coccidioidomycosis infection. Th.pdf
 
Yes,The interthalamic adhesion (also known as the mass intermedia or.pdf
Yes,The interthalamic adhesion (also known as the mass intermedia or.pdfYes,The interthalamic adhesion (also known as the mass intermedia or.pdf
Yes,The interthalamic adhesion (also known as the mass intermedia or.pdf
 
Think of the X and Y as totally different events. The expected value.pdf
Think of the X and Y as totally different events. The expected value.pdfThink of the X and Y as totally different events. The expected value.pdf
Think of the X and Y as totally different events. The expected value.pdf
 
There are two source terms in Maxwell’s equations, the static charge.pdf
There are two source terms in Maxwell’s equations, the static charge.pdfThere are two source terms in Maxwell’s equations, the static charge.pdf
There are two source terms in Maxwell’s equations, the static charge.pdf
 
The xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdf
The xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdfThe xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdf
The xenate ion, [HXeO4]-, slowly decomposes in alkaline solution to .pdf
 
The strengths of the Indian Parliamentary System of governanace1..pdf
The strengths of the Indian Parliamentary System of governanace1..pdfThe strengths of the Indian Parliamentary System of governanace1..pdf
The strengths of the Indian Parliamentary System of governanace1..pdf
 
Pulse code modulationPulse code modulation is a digital sign of a.pdf
Pulse code modulationPulse code modulation is a digital sign of a.pdfPulse code modulationPulse code modulation is a digital sign of a.pdf
Pulse code modulationPulse code modulation is a digital sign of a.pdf
 
D) four s bonds Pi bonds are double bonds as carb.pdf
                     D) four s bonds Pi bonds are double bonds as carb.pdf                     D) four s bonds Pi bonds are double bonds as carb.pdf
D) four s bonds Pi bonds are double bonds as carb.pdf
 
out of Africa hypothesis out of Africa hypothesis is about .pdf
out of Africa hypothesis out of Africa hypothesis is about .pdfout of Africa hypothesis out of Africa hypothesis is about .pdf
out of Africa hypothesis out of Africa hypothesis is about .pdf
 
Leukocytes or WBC They are of two typesGranulocytes Neutrophils.pdf
Leukocytes or WBC They are of two typesGranulocytes Neutrophils.pdfLeukocytes or WBC They are of two typesGranulocytes Neutrophils.pdf
Leukocytes or WBC They are of two typesGranulocytes Neutrophils.pdf
 
In User Interface, Menu Architecture contains the following types.pdf
In User Interface, Menu Architecture contains the following types.pdfIn User Interface, Menu Architecture contains the following types.pdf
In User Interface, Menu Architecture contains the following types.pdf
 

Recently uploaded

Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfElizabeth Walsh
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 

Recently uploaded (20)

Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 

PFA JAVA programimport java.io.; import java.util.; import .pdf

  • 1. PFA JAVA program: import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Bus { static int[] applyPulse(String registers, String pulses) { int[] register=new int[4]; int[] pulse=new int[3]; int i=0; StringTokenizer st = new StringTokenizer(registers," "); while (st.hasMoreElements()) { register[i++]=Integer.parseInt(st.nextElement().toString()); } i=0; st = new StringTokenizer(pulses," "); while (st.hasMoreElements()) { pulse[i++]=Integer.parseInt(st.nextElement().toString()); } //Now ewe have, register [0] is A, register [1] is AB,register [3] is C and register [4] is D if(pulse[0]==1) // if L=1 { register[1]=register[0]; register[2]=register[0]; } if(pulse[0]==1) // if M=1
  • 2. { register[0]=register[3]; } if(pulse[0]==1) // if N=1 { register[1]=register[2]; register[3]=register[2]; } return register; } public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.println("Enter initial values of four regisers A B C D seperated by spaces"); String registers=sc.nextLine(); System.out.println("Ener value of Clock Pulse L M N seperated by spaces"); String pulses=sc.nextLine(); System.out.println("Values of registers A B C D respectively after applying pulse:"); int[] arr=applyPulse(registers,pulses); for(int i=0;i<4;i++) { System.out.print(arr[i]+" "); } } } Solution PFA JAVA program: import java.io.*; import java.util.*;
  • 3. import java.text.*; import java.math.*; import java.util.regex.*; public class Bus { static int[] applyPulse(String registers, String pulses) { int[] register=new int[4]; int[] pulse=new int[3]; int i=0; StringTokenizer st = new StringTokenizer(registers," "); while (st.hasMoreElements()) { register[i++]=Integer.parseInt(st.nextElement().toString()); } i=0; st = new StringTokenizer(pulses," "); while (st.hasMoreElements()) { pulse[i++]=Integer.parseInt(st.nextElement().toString()); } //Now ewe have, register [0] is A, register [1] is AB,register [3] is C and register [4] is D if(pulse[0]==1) // if L=1 { register[1]=register[0]; register[2]=register[0]; } if(pulse[0]==1) // if M=1 { register[0]=register[3]; }
  • 4. if(pulse[0]==1) // if N=1 { register[1]=register[2]; register[3]=register[2]; } return register; } public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.println("Enter initial values of four regisers A B C D seperated by spaces"); String registers=sc.nextLine(); System.out.println("Ener value of Clock Pulse L M N seperated by spaces"); String pulses=sc.nextLine(); System.out.println("Values of registers A B C D respectively after applying pulse:"); int[] arr=applyPulse(registers,pulses); for(int i=0;i<4;i++) { System.out.print(arr[i]+" "); } } }