in java Declare a FileOutputStream named fileStream and a PrintWriter named outFS. Ex: If the input is data.txt Ahmed, then data.txt contains: Ahmed purchased melons 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import java.io.IOException; public class MelonDataProcessor { publicstaticvoidmain(String[] args) throwsIOException { Scannerscnr=newScanner(System.in); StringdataFileName; StringmelonOrder; /* Additional variable declarations go here */ dataFileName=scnr.next(); fileStream=newFileOutputStream(dataFileName); outFS=newPrintWriter(fileStream); melonOrder=scnr.next(); outFS.println(melonOrder+" purchased melons"); outFS.close(); } }
Q: What is the significance of using external style sheets in web development and how do they differ…
A: External style sheets plays a vital role in web development, since they separate the design from the…
Q: In Traceroute why can the round-trip delay of packet be different than the round-trip delay of…
A: 1) Traceroute is a network diagnostic tool used to track the route that packets take across an…
Q: What is the security of the data types exhibited in the below C++ program? C++ source code: //…
A: 1) The security of data types in this context is achieved through the proper use of mutexes and…
Q: I am trying to write a function using python that receives a list and builds a dictionary containing…
A: last_appearance_dict(lst): 1. Initialize an empty dictionary last_appearance. 2. Iterate…
Q: Let Σ2 be the same as in Problem 1.33. Consider each row to be a binary number and let D = {w € |…
A: SOLUTION -A binary number is greater than the other if sees a '1' earlier than the other. For…
Q: Can you write a program in Python which allows the user to input 3 sets (A,B,C) and to display the…
A: Function input_set(prompt)Input: A string prompt representing the message to be displayed to the…
Q: RAM PROCESS 1 PROCESS 2 PROCESS 3 PROCESS 4 Operating tem 800K B) 400K+50 C) 100K+50 +1 D) 200K-50…
A: Memory, in the context of computers, refers to the electronic storage space used to store and…
Q: Need an HTML Code with inlined elements Build this initial home page inside a 2x2 html table. Using…
A: The objective of the question is to create an HTML page with a 2x2 table. The table should have…
Q: In Java programming, when is it appropriate to use built-in exceptions?
A: The objective of the question is to understand when it is appropriate to use built-in exceptions in…
Q: 10.) Which of the following is wrong for swapping? A.)Memory management is easier than fixed…
A: 1) Swapping is a memory management technique that allows the operating system to temporarily move…
Q: What is the security of the data types exhibited in the below C++ program?
A: In the provided C++ program, the concept of multithreading is explored to concurrently execute two…
Q: Consider your apps installed on a smartphone. What data do you think is collected and shared between…
A: Installed apps on a smartphone often collect and share data with app creators and phone companies.…
Q: What are the characteristics of an interpreted programming language?
A: Interpreted programming languages are a type of programming language where the source code is…
Q: You work as an IT engineer for a small corporate network. The office network is consisted of 25…
A: 1) DHCP (Dynamic Host Configuration Protocol) is a network protocol used to automatically assign and…
Q: For any string w = w1w2 · · · wn, the reverse of w, written w R, is the string w in reverse order,…
A: We need to prove that if language A is regular, then AR is also regular. Concepts: A language is…
Q: What is the absolute and relative errors in approximating: 1) π by 22/7 2) 1/3 by 0.333? (You may…
A: Approximation errors play a crucial role in numerical analysis, assessing the disparity between an…
Q: Microsoft has developed powerful Al and facial recognition tools. What is the company's current…
A: Biometric technology known as face recognition uses a person's distinctive facial traits to identify…
Q: Design a simple relational database schema for a library management system. Include tables for…
A: in this question you asked to design a simple relational database schema for a library management…
Q: Which is true about 5G ? OA) 5G signals weaken more rapidly than 4G and travel only 50% as far O B)…
A: Here's some information about 5G:Speed: 5G can be much faster than 4G, with peak data rates of up to…
Q: In my Introduction to Electronics course (300), we often run across division by zero. I know that it…
A: In the field of electronics and circuit analysis, division by zero is encountered in various…
Q: There are a few errors in this html code: All h1 tags must have the color "green" All li tags must…
A: 1. Start2. Declare the HTML document type with <!DOCTYPE html>3. Open the HTML document with…
Q: Part 1 (5): Start by creating a new class called MyPoint that can be initialized with either of…
A: Class Definition:The class MyPoint encapsulates the properties and behaviors of a point, such as its…
Q: Write a Java or a C++ program to do the following USING ARRAYS only (no functions no methods) NO…
A: Step-1) Taking 15 integers as user input.Step-2) Then, display the menu for choice.Step-3) After…
Q: Arduino Mega 2560 2. Wireless Communication 3. Alert System 4. ADXL345 Accelerometer 5. Seismic…
A: Arduino Mega 2560: Arduino Mega 2560 is a microcontroller board based on the ATmega2560, designed…
Q: Create a TestDeck project with a TestDeck class, a Deck class and your Card class from project…
A: In this question we have to write a simple card game setup involving a deck of cards and two…
Q: Calculate 5x2 using Booth's algorithms (assuming two's complement number representation)
A: Booth's Algorithm is a multiplication algorithm used for signed binary numbers represented in two's…
Q: In the following Deterministic Finite Automaton (DFA): 1 S₁ 0 0 S₂ 1 What statement(s) correctly…
A: A mathematical model called a Deterministic Finite Automaton (DFA) is used to identify patterns in…
Q: 1. Give a big-Oh characterization, in terms of n, of the running time of following methods. 1 /**…
A: The objective of the question is to determine the Big O notation for the running time of the given…
Q: Write a Java program that generates detailed information about an available accommodation. The…
A: Set accommodationType to "Fully Renovated House (Main Floor)"Set features to "2 Unfurnished…
Q: Create the Matrix: Create a 19x19 matrix with values starting from 1 to 361. Modify the Middle:…
A: In the first step, the code created a matrix with the specified range.Then in the second step, it…
Q: What are some vulnerabilities exhibited with use of strings in C++?
A: The question is asking about the potential vulnerabilities or risks that can occur when using…
Q: 4. Suppose the memory cells at addresses Ox00 through 0x05 in the Vole contain the following bit…
A: The memory address of the subsequent instruction to be fetched and executed is stored in a register…
Q: Solve the following system of equations using Cramer’s rule. (You may use MATLAB to calculate…
A: In this question we have to write a MATLAB code for the given equations using Cramer’s rule.Let's…
Q: write a java program that implements the insertion sort algorithum that sorts list of doubles in the…
A: The basic insertion sort method incrementally sorts an array. It efficiently sorts a list by…
Q: Write a program that asks the user to enter a month (1 for January, 2 for February, etc.) and then…
A: This question comes from programming language which is a topic in computer science. In this question…
Q: Suppose that preferences in a stable matching instance are universal: all n jobs share the prefer-…
A: Examining stable matching issues from the perspective of universal preferences provides a…
Q: Map the ER diagram shown (ER diagram for Area-Law - a law firm) into a relational schema. Show all…
A: A relational database can be organized and structured using a basic blueprint called the relational…
Q: For pyhton: Write a program to prompt the user for hours and rate per hour to compute gross pay.…
A: 1) Below is python program to prompt the user for hours and rate per hour to compute gross pay.The…
Q: import java.util.Scanner; public class NumberPattern { // TODO: Write recursive…
A: The Java application `NumberPattern` generates a certain number pattern through recursion.…
Q: 1.12 Let D = {w| w contains an even number of a’s and an odd number of b’s and does not contain the…
A: A DFA (Deterministic Finite Automaton) is a finite state machine which recognizes or generates the…
Q: 12) The given HTML is used to create formatted text. Article AArticle BArticle C What is the…
A: HTML stands for HyperText Markup Language which is used to design and structure web pages using…
Q: in java Double width and integer amountCompleted are read from input. Output the following: width…
A: The objective of the question is to format and print the input values in different notations. The…
Q: Instructions: Write a program that produces the following output: ссссссссс Сс Сс cc Сс ССССССССС ++…
A: Initialize a loop with the variable i ranging from 0 to 5 (inclusive).For each iteration of the…
Q: Develop a Java application to have the user input a positive four-digit integer at the keyboard.
A: 1: Create a scanner object with the variable name ‘sc’2: Declare a variable called ‘number’ to store…
Q: 2nd element in Fibonacci sequence Test feedback fibonacci (2) correctly returned 1 Test negative…
A: 1) Below is your updated Java program to check fibonacci of a number.The program calculates the…
Q: An all-NFA M is a 5-tuple (Q, E, 6, 9o, F) that accepts x € Σ* if every possible state that M could…
A: We provide two formal definitions for all-NFAs: one with ε-transitions (like the NFA in class) and…
Q: Sites like Zillow get input about house prices from a database and provide nice summaries for…
A: SOLUTION -We have solved this problem in Java code with comments and screenshots for easy…
Q: Write up a paragraph or two describing the four memory allocation functions provided in the C…
A: [ Note: As per our policy guidelines, in case of multiple different questions, we are allowed to…
Q: The 10 Richest People in the World 2023 (Excel) Rank Name Age Wealth ($bil) Wealth per year 1…
A: In this question we have been given the data for top 10 richest people in the world. We have to…
Q: Choose a television game show such as Wheel of Fortune or Jeopardy! and describe its rules using a…
A: Note: I chose the game Jeopardy. Jeopardy is an American television game show. Merv Griffin created…
in java
Declare a FileOutputStream named fileStream and a PrintWriter named outFS.
Ex: If the input is data.txt Ahmed, then data.txt contains:
Ahmed purchased melons
Unlock instant AI solutions
Tap the button
to generate a solution
Click the button to generate
a solution
- import java.util.Scanner;import java.io.FileInputStream;import java.io.FileOutputStream;import java.text.DecimalFormat;import java.io.IOException; public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); // Initialize variables for calculating exam averages int count = 0; double sumMid1 = 0, sumMid2 = 0, sumFinal = 0; // Initialize FileOutputStream for output FileOutputStream fos = new FileOutputStream("report.txt"); // Prompt for the filename System.out.print("Enter the name of the TSV file: "); String fileName = scnr.nextLine(); FileInputStream fis = null; try { fis = new FileInputStream(fileName); // Read the file and build the content string StringBuilder sb = new StringBuilder(); int ch; while ((ch = fis.read()) != -1) { sb.append((char) ch); }…import java.util.Scanner;import java.io.File;import java.io.IOException;public class test2{public static void main(String [] args)throws IOException{File database = new File ("flights.txt");Scanner fileReader = new Scanner( database );Scanner input = new Scanner(System.in);// Displays the welcome screenint menuCheck = 0;String city = "";float oneWayCost = 0f;float roundTripCost = 0f;int numberOfSeats = 0;float total = 0f;while (menuCheck == 0){System.out.println("Welcome TO MEjia AIRLINES.");System.out.println("Please select a choice below [1-5]");System.out.println(" 1. Add flight");System.out.println(" 2. View trip");System.out.println(" 3. Manage Trip");System.out.println(" 4. Checkout");System.out.println(" 5. Exit Mejia airlines");int userInput = input.nextInt();if (userInput == 5){System.out.println("Thank You for using Mejia airlines");System.out.println("Stay safe! Stay Hrydrated! Happy Coding!");menuCheck = -5;}else if (userInput == 1){menuCheck = 1;}else if (userInput ==…package Rayjack_Lab03;import java.util.Scanner;public class RayJack_Lab03 {public static void main(String []args) {Scanner sc= new Scanner(System.in); //System.in is a standard input stream.int firstNum,secondNum;System.out.print("enter first value: ");firstNum=sc.nextInt();System.out.print("enter second value: ");secondNum=sc.nextInt();if (firstNum>=secondNum)System.out.println("It is True to say that first value "+firstNum+" is larger or equal to Second value"+secondNum);elseSystem.out.println("It is False to say that first value "+firstNum+" is larger or equal to Second value "+secondNum);}}Q. Please guide on how to take decimal values in this proggram's output as well.
- import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Scanner;class MyException extends Exception{public MyException(String NegativeArraySizeException){System.out.println("The integer must be in between 1 and 20");}}public class arrayTwo {public static void main(String[]args){Scanner keyboard = new Scanner(System.in);System.out.println("How many integers do you have? (Max 20)");int[] num = new int[keyboard.nextInt()];if(num.length<=0 || num.length>20) {System.out.println("You must enter a number in between 1 and 20");}elsefor (int i = 0; i < num.length; i++) {System.out.println("Enter element for subscript " + i);num[i] = keyboard.nextInt();}System.out.println("Here are all of those numbers");for (int i = 0; i < num.length; i++) {System.out.println(num[i]);}}} attempted to use this code to fix the exception when a negative number is entered by the user, but it still gives back the exception. I would like to know how to…import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Scanner;class MyException extends Exception{public MyException(String NegativeArraySizeException){System.out.println("The integer must be in between 1 and 20");}}public class arrayTwo {public static void main(String[]args){Scanner keyboard = new Scanner(System.in);System.out.println("How many integers do you have? (Max 20)");int[] num = new int[keyboard.nextInt()];if(num.length<=0 || num.length>20) {System.out.println("You must enter a number in between 1 and 20");}elsefor (int i = 0; i < num.length; i++) {System.out.println("Enter element for subscript " + i);num[i] = keyboard.nextInt();}System.out.println("Here are all of those numbers");for (int i = 0; i < num.length; i++) {System.out.println(num[i]);}}} Need to figure out the code to get rid of the exception for inputting a negative as an array size.import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.util.Scanner;public class romeoJuliet {public static void main(String[]args) throws Exception{Scanner keyboard=new Scanner(System.in);System.out.println("Enter a filename");String fN=keyboard.nextLine();int wLC=0, lC=0;String sW= keyboard.nextLine();File file=new File(fN);String [] wordSent=null;FileReader fO=new FileReader(fN);BufferedReader buff= new BufferedReader(fO);String sent;while((sent=buff.readLine())!=null){if(sent.contains(sW)){wLC++;}lC++;}System.out.println(fN+" has "+lC+" lines");System.out.println("Enter some text");System.out.println(wLC+" line(s) contain \""+sW+"\"");fO.close();}} Need to adjust code so that it reads all of the words that it was tasked to find. for some reason it isn't finding all of the word locations in a text. for example the first question is to find "the" in romeo and juliet which should have 1137, but it's only picking up 1032?
- in java Declare a FileInputStream named gradeFStream and a Scanner named gradeFS. Click here for example GradeDataProcessor.java input1.tx tinput2.txt input3.txt public class GradeDataProcessor { publicstaticvoidmain(String[] args) throwsIOException { Scannerscnr=newScanner(System.in); StringfileName; chargradeGrade; /* Variable declarations go here */ fileName=scnr.next(); gradeFStream=newFileInputStream(fileName); gradeFS=newScanner(gradeFStream); gradeGrade=gradeFS.next().charAt(0); System.out.println(gradeGrade); gradeFStream.close(); } }import java.util.Scanner;import java.io.FileInputStream;import java.io.IOException; public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }}Write an application that displays the sizes of the files lyric1.txt and lyric2.txt in bytes as well as the ratio of their sizes to each other. Here is the code so far: import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOException; public class FileSizeComparison { public static void main(String[] args) { Path textFile = Paths.get("/root/sandbox/lyric1.txt"); Path wordFile = Paths.get("/root/sandbox/lyric2.txt"); // Write your code here } }
- ExampleTwo This program loops through fileLoop.txt, computation, and display results package charioloop; import java.util.Scanner; import java.io.*; // public class Charioloop { public static void main(String[] args) throws IOException { //Create a reference to the physical file File loopfile = new File("fileLoop.txt"); // connect a Scanner to the file Scanner getAll = new Scanner( loopfile ); int num = 0, square = 0; while(num != -1){ num = getAll.nextInt(); square = num * num ; System.out.println("The square of " + num + " is " + square); } getAll.close(); } } /* Create fileLoop.txt in I:\\Ajava\161\WPPractice\IO\charstream\charioloop My fileLoop.txt looks like this: 2 3\ 2 10 -1 Note:- Study this program and follow the given instruction and execute type the code and provide also output for this java program as soon as possible.I need help with fixing this java program as described in the image below: import java.util.Scanner;import java.io.FileInputStream;import java.io.IOException; public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); // Read the file name from the user String fileName = scnr.nextLine(); // Open the CSV file try (Scanner fileScanner = new Scanner(new FileInputStream(fileName))) { while (fileScanner.hasNextLine()) { // Read each line from the CSV file String line = fileScanner.nextLine(); // Split the line into showtime, title, and rating String[] movieData = line.split(","); // Extract showtime, title, and rating String showtime = movieData[0]; String title = movieData[1].length() > 44 ? movieData[1].substring(0, 44) : movieData[1]; String rating = movieData[2]; // Print the…// Program describes two files // tells you which one is newer and which one is larger import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOException; public class DebugThirteen1 { public static void main(String[] args) { Path file1 = Paths.get("/root/sandbox/DebugDataOne1"); Path file2 = Paths.get("/root/sandbox/DebugDataOne2.txt"); try { BasicFileAttributes attr1 = Files.readAttributes(file1, BasicFileAttributes.class); System.out.println("File: " + file1getFileName()); System.out.println("Creation time " + attr1.creationTime()); System.out.println("Last modified time " + attr1lastModifiedTime()); System.out.println("Size " + attr1.size()); BasicFileAttributes attr2 = Files.readAttributes(file2, BasicFileAttributes.class); System.out.println("\nFile: " + file2.getFileName); System.out.println("Creation time " +…