Write this java program which has two threads in them: 1. Open an input file and print in the screen the number of words in each line 2. Open an input file and print in the screen the number of spaces in each line
Q: Write a Java program that print its own source code.
A: This type of program is called Quine. The quine is program which takes no input and produce a copy…
Q: This is for Advanced Java Programming Produce a class titled ThreeThreads. Inside this class, you…
A: import java.util.*; import java.lang.*; // thread 1 generates random character (a-z) class…
Q: Please implement a Pop() operation on a stack in Java. 1. The program should read in 18 different…
A: Ans:) Please follow the given instructions carefully: There are 3 main files in this project:…
Q: In Java Suppose you are given a text file that contains the names of people. Every name in the file…
A: 1. Open the input file for reading2. Open the output file for writing3. Initialize an empty array of…
Q: Write Java a program that will record the purchases made at a store. For each purchase, read from…
A: import java.io.FileWriter; import java.util.Scanner; public class Main{ public static void…
Q: Write a Java program that allows the user to specify a file name on the command line and prints the…
A: import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import…
Q: Assume that we have a file named “sharable.txt" that can be shared among several threads. We want to…
A: The program is given below. The comments are provided for the better understanding of the logic.…
Q: Write a Java program that reads in a paragraph of text from a file and prompts the user to enter a…
A: I have provided JAVA CODE along with CODE SCREENSHOT , TXT FILE SCREENSHOT , CODE S CREENSHOT…
Q: Chapter 9. PC #14. Word Separator (modified *** Read carefully ***) Write a program that prompts the…
A: The scope of the question pertains to the behavior and output of the provided Java program,…
Q: Write a Java Program to perform the following operations using FileOutputStream and FileInputStream…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: JAVA Using a text editor write a "Hello World" program in Java. This should produce a .java text…
A: 1. creating a java file containing the Hello world helloWorld.java file class HelloWorld {…
Q: Write a JAVA program that will keep track of the purchases made at a store. Assuming that the…
A: Required java code is given below:
Q: Write a complete Java program: You have text file called "file.txt" read the contents of…
A: I have given an answer in step 2.
Q: Let the program repeat the steps three times using a loop
A: The complete JAVA code for the given problem statement is shown below. Have a look.…
Q: Create a file with the name "BankAccount.txt" and has the following content (the account name,…
A: Note: As per the Bartleby policy, we can solve only one question at a time. Please post the…
Q: Write a Java program that simulates a meeting reservation system. The program shall allow the user…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Develop a server program in java that waits for clients to connect. The server responds to the…
A: Java is a high level programming language... And also object oriented ... It. Is a platform for…
Q: Write a Java program that asks a user to input a text file name which contains no punctuations reads…
A:
Q: I am trying to make a java program with three threads. two representing client bob and Alice. a…
A: Hers is the solution
Q: Write a java program that reads a file named input.txt and writes a file that contains the same…
A: Required java code along with sample output given below:
Q: Using the Java programming language write a program that takes an email address as an input from the…
A: Please refer below commented code with output screenshot: import java.util.*;class Valid_email {…
Q: Write a Java program to file student information in a student directory of your project folder.…
A: Below is the complete java code with comments.Snapshots of the output console are also attached.…
Q: Write a program that reads a file one character at a time and prints out how many characters are…
A: File name: “Characters.java” import java.io.File; import java.io.FileInputStream; import…
Q: Select all true statements import java.io.File; import java.util.Scanner; public class…
A: length() method: The length() method is a function available in the java.io.File class. It returns…
Q: Write a Java program that reads from a URL and searches for a given word in the URL and creates a…
A: In this question we have to write a Java program that reads from a URL and searches for a given word…
Q: Write a Java program to get and display information (year, month, day, hour, minute) of a default…
A: Given; Write a Java program to get and display information (year, month, day, hour, minute) of a…
Q: Write a java program that finds the number in the range 1 to some maximum that has the largest…
A: Write a java program that finds the number in the range 1 to some maximum that has the largest…
Q: Write a java program that prints out the following song: Hello all, hope you're fine Hello all, hope…
A: here is the code snippet : public class Main { public static void main(String[] args)…
Step by step
Solved in 5 steps with 5 images
- answer for thisWrite a Java program that print its own source code. Note: Don't use any file pathhelp I am trying to make a java program with three threads. two representing client bob and Alice. a third thread representing a mail server. make Alice check their mailbox every 5 second if their is a mail form bob, Alice should send one back and bob should do the same thing. Pre-load Alice's mailbox with one mail from Bob. For the next minute or so, Alice should check for mail every 5 seconds and Bob should check for mail every 3 seconds. If they receive a mail, they should send one back. The body of the first mail should say "Hello", the body of the second mail should say "Hello Hello", and so on. Design a Mail class that has fields From, To, Date, Body. here is what I have but Im lost public class mailserver2 extends Thread{public boolean maildeliverd;public boolean maildeliverbob; public void checkMail(){ try{while (maildeliverd){Thread.sleep(5000); }}catch(Exception e){System.out.print("mail not recieved");}System.out.print("mail recieved");mailclass mc = new…
- Write a java program that finds the number in the range 1 to some maximum that has the largest number of divisors. It prints that number and the number of divisors that it has. Note that there might be several numbers that have the maximum number of divisors. Only one of them is output. The program's work is divided among one to ten threads. The number of threads is chosen by the user.write a program that consists of two threads. The first is the main thread that every Java application has. The main thread should create a new thread from the Runnable object, MessageLoop, and wait for it to finish. If the MessageLoop thread takes too long to finish, the main thread should interrupt it. Use a variable named maxWaitTime to store the maximum number of seconds to wait. The main thread should output a message stating that it is still waiting every half second. The MessageLoop thread should print out a series of 4 messages. 4 means 4. If you use 5 messages, you will receive a 0. These messages should be numbered, as in the example below. It should wait 850 milliseconds between printing messages to create a delay. If it is interrupted before it has printed all its messages, the MessageLoop thread should print "Message loop interrupted" and exit. Or you can let main print "Message loop interrupted" as in the sample output. The MessageLoop thread must try to output all 4…Give Answer please.
- This is for Advanced Java Programming Produce a class titled ThreeThreads. Inside this class, you are to use three threads to output three types of characters to a text area for display. In the first thread, you are to output random letter characters such as a, b, c, d … In the second thread, you are to output random number digits such as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 In the third thread, you are to output random characters such as !, @, #, $, %, &, * Display a minimum of 10,000 of each of the three sets. Write test code that ensures all methods function correctlyAssume that we have a file named “sharable.txt" that can be shared among several threads. We want to write a program that controls the access to that file in a way that only one thread at a time is allowed to access that file (i.e., for writing/appending purposes). Using Java multithreading, write a program that creates three threads and assigns a number to each thread. Then, each thread will start running by executing a code for opening the file "sharable.txt" and writing the following lines: Thread x started writing Thread x is currently writing Thread x finished writing Your program should allow only one thread -at any given time-to access the file and write in it. It also should keep away any thread from overwriting the lines written by any other threads (hint: use synchronized method/blocks). Finally, when the execution of the program is completed, the output stored in “sharable.txt" should look like the following: Thread x started writing Thread x is currently writing Thread x…Java program Assume there are two public phone booths in your area. Each person is allotted a fixed time of 1000 milliseconds for a call beyond which the turn goes to the next waiting person Assume n customers are making a call in a day Each customer waits for their turn if both the booths are under use. Write a program using multi threading to find the number of customers served by each booth and the order of customers call.
- Write a Java program to file student information in a student directory of your project folder. Create a student directory in your project directory to store all student file. Each file should have the student name, age, major and gender. Each of these student entriesshould be on a separate line.The Programming Language is; JAVA Please write comments in each part write a program about a e-shopping order menu. While doing this use OOP concepts. Implement a stocking program using threads. You have an e-store and customer side. In the frame: Number of Items (TextField): Number of items in the stock.() Create (Button): Creates items and adds them to frame. (Pen, paper, bag,etc.) Good (Button): Agents/Customer’s basket start to number of goods/items.(Customer wants to buy 3 pens) Number of Agents (TextField): How many customers at one time? (You can create an arbitrary maximum number if you explain.I.e maximum 4 customers because,...) Maximum Waiting Time (Text Field): Agents or customer’s basket will wait for some time after booking an item. The waiting time will be a random number between 0 and the number entered in this text field. Waiting times must be different for each agent. When waiting time is up, threads (baskets) will release their hold on items. So If your…10. Write a multi-threading JAVA program having four threads:- The “Generator” thread: it takes as argument (in the constructor) aninteger N and generates an array of N integers- The “Even” thread: it takes as argument (in the constructor) an array ofintegers and counts the number of even numbers in the array- The “Odd” thread: it takes as argument (in the constructor) an array ofintegers and count the number of odd numbers in the array- The main thread:o it asks the user to enter an integer No Then, it runs the “Generator” thread to create an array of integersand waits the end of “Generator”o Then, it run “Even” and “Odd” to count the number of even andodd numbers in the generated arrayo Finally, it prints if there is more even or odd numbersNote: the main thread should wait the end of “Even” and “Odd”threads before printing the final result.