When reading data from a text file, it is common to see numbers such as 12,345, $20, or 195*. Write a method that cleans a string containing digits by removing any characters that are not a digit or a - sign. Then convert to an integer and return the result. Numbers.java 1 public class Numbers 2 { /** Cleans a string containing an integer and converts it. @param number a string containing an integer and possibly extra characters @return the value of the number inside the string * / blic static int clean(String number) { 4 5 7 8 9 10 11 } 12 }
Q: Write a method called wordLengths that accepts a Scanner for an input file as its parameter. Your…
A: Please find the answer below :
Q: How do I create in Java create a public static method named manipulateString that asks the user…
A: import java.util.Scanner;public class FinalExamAnswer{ public static void main(String…
Q: would like my program to print out a physical receipt (PDF or any file) once the user has made their…
A: Program Approach: 1- Yes, the user can write all the information into the text file. 2- With the…
Q: Given the String String str = “Zhrx.aghkio.Gko123”; (a) Write Java code using the String class…
A: Answer : public class StringDemo { public static void main(String[] args) { String str =…
Q: Write a method called stripComments that accepts a Scanner representing an input file containing a…
A: A Java file with comments was first made and saved. Then another java program is written with reads…
Q: do I edit the code to correctly display the number of available burgers and the waiting customers?…
A: It is defined as a high level, robust, object-oriented and secure programming language. The features…
Q: Using Java Create a text file using the following books: And Then It's Spring Baby Bear Sees…
A: EXPLANATION: - The classes present in the io package named BufferedWriter, File, FileWriter, and…
Q: Write an application that accepts any number of String values from a user until they enter zzz or…
A: Above code need to be modified because for loop cannot help to maintain user input loop as it is…
Q: Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each…
A: The following corrections need to be made to the program: In the while loop, logical and…
Q: I need this debugged. Thanks in advance. // Application allows user to enter a series of words //…
A: Error1: final String STOP = XXX; You have declared STOP as string but didn't placed it in double…
Q: (in java) add a part where you print user information and update the continue watching list in…
A: Here , we have given the java class named Netflix. We need to create the two objects of this class…
Q: Write a static void method that accepts as its only parameter a string file name. Using the data…
A: EXPLANATION: - static void readFile(String filename) : - The file read operation is performed with…
Q: Student.java and fills the contents from your main method as follows. class Student{ String name;…
A: Please find the JAVA Code below:
Q: Write a program that will prompt the user to enter a sentence (string data), read that entire…
A: I give the code in Java along with code and output screenshot
Q: Write a method named stringTimes that is passed a String parameter word and a positive integer num.…
A: public class Main{ public static String stringTimes(String str,int num){ String ans = ""; //…
Q: 1. Write a program that separately prompts the user for a first name and last name and outputs a…
A: As per our guidelines we are supposed to answer?️ only one question. Kindly repost other questions…
Q: a simple java program that reads all the content in a .txt file, the user will enter the filename to…
A: It is defined as a high level, robust, object-oriented and secure programming language. It is known…
Q: Write a method called vowelsInString() that accepts one String argument, and returns the number of…
A: Required: Write a method called vowelsInString() that accepts one String argument, and returns the…
Q: Suppose a Student class has the following attributes and methods: Student: int id (public), String…
A: The java program is given by import java.io.*; import java.util.*; class Student { publicint id;…
Q: Test Case 1 Enter length: \n 5 ENTER Enter width: \n 10 ENTER You entered: 5.0, 10.0, and 50.0 \n…
A: Here I have created all the functions that were given in the question. In the method getLength() and…
Q: Hi, could you help me resolve this java problem? I don't get why it can't accept my "array of (Song)…
A: The only error in our program is that we have missed the attribute title in Song class
Q: Create a class called "Session12Lab". Create a method public static String[] mergeArrays(String[]…
A: Please find the answer below :
Q: 2. Create a Java project named clsProject2 Create a method called public static String [][]…
A: Import the required classes from io package like File and Scanner class. Method get_years-quarters…
Q: Java Write an executable program that has just a main method. In main: create an instance of…
A: In main function: create an instance of StringBuilder that initially holds an empty string. append…
Q: In Java. Sort the list of cars and display them. Sort by make, model, and year. Each car property…
A: Hey there, I am writing the required solution of the above stated question.Please do find the…
Q: Design a class that attempts to determine the relative frequency of each letter by reading a file…
A: Save file as with "txt" I have saved my file as "n.txt" And my file contains below data: i amtejas
Q: Q- I want someone to convert this code to java code ASAP #include using namespace std; class…
A: Find the required code in java as below and output:
Q: Write a method public static intreadInFile(String line, File file) that returns the position…
A: Program Plan: Import necessary libraries required for file creation,BufferedReader,IOException and…
Q: The problem I have is, say I am storing the phone number and don't want their phone number to…
A: import java.util.Scanner; class Clint { private String id; private String name;…
Q: How do I add, If s is null, the method should return null. If s is the blank string, “”, the method…
A: import java.util.Scanner;public class replaceFirst { public static String…
Q: For the ReadWords class that is used to read the content of a given text file, which of the…
A: ANSWER C) public ReadWords() throws FileNotFoundException {...}
Q: a console application for writing data to a sequential text file with a formatter class in Java :
A: 1. create a class to define the file.2. take the location of file from user.3. use catch and throw…
Q: Java, the user selects an item from the text files ranging 1-15, repeats the loop until 'q'. the…
A: import java.io.*; import java.util.*; class BillProcessor { public static void…
Q: In python using beginners methods (no custom classes etc) and small files - How do I have a user…
A: import rebadFile = open('E:\\file.txt', 'r') #read existing fileprint("Old Content…
Q: Write a method that takes a celsius input from user and converts given value to other units of…
A:
Q: Create a main() method in your Sqaure class, which should contain the following code: Rectangle r =…
A: /** Rectangle class, phase 5*/ public class Rectangle { private double length; private double…
Q: Write a method with the following header to format the integerwith the specified width.public static…
A: Here, you need to write one method called "format" , which will return a string for the number with…
Q: For the ReadWords class that is used to read the content of a given text file, which of the…
A: Reason: Constructors don't want a return type specified. That is, a constructor returns the class…
Q: Write an O(n) time program that prompts the user to entertwo strings and tests whether the second…
A: Since the Programming language is not mentioned in the question, we will answer this question in…
Q: Java: Write a static method named textCount that takes a Scanner representing a file as a parameter…
A: Actually, the code has given below:
Q: The extraterrestrials living in the planet Numerion revere a specific type of integers N. In…
A: Program code #1:
Q: Java
A: import java.util.Scanner; public class WordProperties { public static void…
Q: an you please write in java.util.scanner form ,can you please make it so i can copy and past it…
A: I have provided a solution in step2
Q: Write a second convertToInches() with two double parameters, numFeet and numInches, that returns the…
A: Note: The function added in the code is along with the comments to have a better understanding of…
Q: REUPLOAD: I need to fill the program to its designated output I have inserted sample runs and the…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: A palindrome is a string that reads the same both forward and backward. Examples of palindromes are…
A: ALGORITHM:- 1. Take input for the string from the user. 2. Truncate the string so that only…
Q: This is the question - Write an application that accepts any number of String values from a user…
A: import java.util.*;public class StringSort2 { public static void main(String[] args) { Scanner…
Q: * A. Write the method named stringTimes(). * * Given a String str and a non-negative int n, return a…
A: public class PS06A { static String stringTimes(String str, int n) // function to return string into…
Q: A store owner keeps a record of daily cash transactions in a text file. Each line contains three…
A: Given
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- create a class that asks a user for 2 string inputs (USE The Java. Util. SCANNER) -compare the two strings and output if they are equal or not. -check the length of the 2 strings. then compare the two (in terms of length) -thereafter, for the largest string, ask the user to input a character and determine if the string contains that specific character ..... e.g. The word is "star" and the user enters 'a'. The program should output either True or False 2) Create another method within the same class that will check if a sequence of characters (String) entered by the user to determine whether or not the String contains that specific sequence. -You can use the user input from Q1 to determine if the string contains the sequence of characters. You need to create atleast 2 methods (excluding the main method). Atleast one Method needs to take in argument and return some value 3) Create a Person class that…The extraterrestrials living in the planet Numerion revere a specific type of integers N. In particular, for those creatures, an integer N is holy if there exists an integer i >= 1 such that:N = i*i + iHere are some examples of holy numbers:2 (because 2 = 1*1 + 1) 6 (because 6 = 2*2 + 2) 12 (because 12 = 3*3 + 3) In a file called Numerion.java, write a program that: Asks the user to enter an integer N. It is OK if your program crashes when the user does not enter a valid integer. Prints out whether that number is a holy number in planet Numerion. For example: if the user enters 25, your program output should look EXACTLY like this: Enter an integer N: 25 25 is not a holy number in Numerion. Exiting... As another example: if the user enters 12 (a holy number, since 12 = 3*3 + 3), your program output should look EXACTLY like this:Enter an integer N: 12 12 is a holy number in Numerion. Exiting...In java, without Arrays and using only String methods ( don't use String builder) // Question 17: In MS-DOS, a file name consists of up // to 8 characters (excluding '.', ':', backslask, '?', // and '*'), followed by an optional dot ('.' character) // and extension. The extension may contain zero to three // characters. For example, 1STFILE.TXT is a valid filename. // Filenames are case-blind. // // Write and test a method that takes // in a String, validates it as a valid MS-DOS file // name, appends the extensions ".TXT" if no extension // is given (that is, no '.' appears in FILENAME), converts // the name to uppercase, and returns the resulting string // to the calling method // If fileName ends with a dot, remove that dot and do not // append the default extension. If the name is invalid, // validFileName should return null. public String validFileName(String n) { }
- Here is the code i am working with, around the last line it says what i need to do, any help please! import java.util.*; import java.io.*; public class FileLoader implements Getter { String [][] data; String [] head; String FILENAME = "wv-covid-daily.csv"; String DELIMITER = ","; int MAX_ROW; int MAX_COL; int dataRows; boolean stillLoading; public FileLoader () { MAX_ROW = 100; MAX_COL = 50; dataRows = 0; data = new String[MAX_ROW][MAX_COL]; head = new String[MAX_COL]; stillLoading = false; } public int getNumRows() { return dataRows; } public String [] getRow (int row) { return data[row]; } public boolean isLoading () { return stillLoading; } public void run () { stillLoading = true; dataRows = 0; try { String line; int row = 0; BufferedReader reader = new BufferedReader(new FileReader(FILENAME)); if((line=reader.readLine())!=null){ String fields[] = line.split(DELIMITER); head=fields; } while((line=reader.readLine())!=null){ String fields[] = line.split(DELIMITER);…This is the question I am stuck on - Write an application that accepts any number of String values from a user until they enter zzz or have entered 15 strings, and display them in ascending order. This is the code I have started to try but I am honestly just confusing myself more - import java.util.*; public class StringSort2 { public static void main(String[] args) { // Write your code here Scanner input = new Scanner(System.in); String values; int x; System.out.println("Please enter your values: "); values = input.nextLine(); for(x=15; x < values.length; ++x) System.out.println(values[x] + " "); } }Given the String String str = “Zhrx.aghkio.Gko123”; (a) Write Java code using the String class methods indexOf and substring to extract the three string surrounded by the periods. In other words String s1 will contain Zhrx, String s2 will contain aghkio and String s3 will contain Gko123. (b) Write a method of the form public static String minstr(String str1, String str2) which returns the string which is “smaller” based on the decimal values of the characters in the string. Thus, Zaa would be “smaller” than bxy because the character Z has a lower decimal values than b. Use the String method compareTo as part of your code. (c) In main, print the value returned by minStr(minStr(s1,s2),s3)
- can you please write in java.util.scanner form ,can you please make it so i can copy and past it int[] numbers = {345, 632, 675, 157, 834, 294, 832};1. Write a method to find its highest value. 2. Write a method to find its lowest value. 3. Write a method to find its total value.Write a java program call CountVowelsDigits which prompts the user for a string, counts the number of vowels(a,e,i,o,u,A,E,I,O,U) and digits(0-9) contain in the string, and prints the counts and percentages rounded to 2 decimal places. Enter a String : testing12345 Number of vowels is: 2 (16.67%) Number of digits is : 5 (41.67%)Write a method public static intreadInFile(String line, File file) that returns the position numberof a line in the file filename or −1 if there is no such line or file.We assume that this file contains names of people with a name per line.Names (and hence lines) are listed in ascending alphabetical order in the file.We can not find the same line twice.
- Write a program that reads a text file named as “input.txt” and performs the following operations:1. Write each word in the text file in reverse order to the file named as“output.txt” . (Example: If the text file contains ”Hello World!”, then itshould write to the output file ”olleH dlroW!”)2. Print the number of words.3. Print the number of words starting with a capital letter.4. Print the number of words that contain no characters other than Englishletters.In this challenge you are supposed to:1. Comment every function with a description explaining what it does andhow it does it.2. Research and learn how to read and write into text files by using properlibrary functions in C.In your program, you can assume that1. Both the input file (input.txt) and the output file (output.txt) will beplaced on the same folder as your program’s executable (.exe).2. In the input file, the length of the words will be at most 100.IN JAVA Write a program that replaces each line of a file with its reverse. For example, if you run java Reverse HelloPrinter.java Create the output as HelloPrinterReverse.java. If the file HelloPrinter.java contains the text public class HelloPrinter { public static void main(String[] args) { // Display a greeting in the console window System.out.println("Hello, World!"); } } ?? then the contents are changed to retnirPolleH ssalc cilbup { )sgra ][gnirtS(niam diov citats cilbup { wodniw elosnoc eht ni gniteerg a yalpsiD // ;)"!dlroW ,olleH"(nltnirp.tuo.metsyS } } If there is a blank line in the input file, do not print it in the output file. If you run Reverse twice on the same file, you get back the original file. Create the output file as HelloPointerOriginal.java java Reverse HelloPrinterReverse.java If the input file doesn’t exist, throw the message “Input file not found. Please check an rerun the program”. Allow the user to enter the input file one more time. If the user enters an…In Java please. Only aswer the code where it says "/* Your code goes here */". Write a method lastNameFirst that takes a string containing a name such as "Harry Smith" or "Mary Jane Lee", and that returns the string with the last name first, such as "Smith, Harry" or "Lee, Mary Jane". import java.util.Scanner; public class Names{ /** Changes a name so that the last name comes first. If name has no spaces, it is returned without change. @param name a name such as "Mary Jane Lee" @return the reversed name, such as "Lee, Mary Jane". */ public static String lastNameFirst(String name) { /* Your code goes here */ } public static void main(String[] args) { Scanner in = new Scanner(System.in); String name = in.nextLine(); System.out.println(lastNameFirst(name)); }}