Concept explainers
Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
Modern Database Management (12th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Problem Solving with C++ (10th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out with Java: Early Objects (6th Edition)
- Implement (in Java) a console application for writing data to a sequential text file with a formatter class in Java : a. Implement createFile() method – To open/create a new file named as ‘mec.txt’ with explanations of the methods involved. b. Implement writeRecord() method – User enter the employee name, employee id, gross salary, tax rate, income tax and net salary from the keyboard and write/add these values to the file ‘mec.txt’ with explanations of the methods involved. The input fields must be validated as necessary. c. Implement closeFile() method – Close the file with explanations of the methods involved.arrow_forwardFor this exercise, you will create 2 classes: InputOutput class and AddNumbers class. ⦁ InputOutput Class: write a program that carries out the following tasks:⦁ Create an object of type PrintWriter and that writes into a file with the name greeting.txt.⦁ Print the message “Hello, world!” on the file.⦁ Close the file.⦁ Open the same file again.⦁ Read the message into a string variable (hint: use nextLine() method to read the text).⦁ Print the message on the screen. ⦁ AddNumbers Class: write a program that asks the user to input four floating-point numbers. Add all correctly specified values and print the sum when the user is done entering data. Use exception handling to detect improper inputs. For example, the user might enter letters instead of numbers. In this case, use the exception handling mechanism to print a proper message. (hint: use InputMismatchException) Don’t forget to import java.util.*.arrow_forwardWrite a program to create a class students having name, id, age. Create a file “student.txt” and open in append mode. Write the detail of 3 students into a file and read the data from the file and display on screen. Also copy content of this file into another file.arrow_forward
- Write a program that opens a file me.txt and write your first name followed by a space followed by your last name, then your major on the second line. If the file does not exist, create it. If the file exists, have the file's contents be erased before writing your name. Be sure to close the file after. Example: Barack Obama Political Science Majorarrow_forwardcreate a class named FileUtils. Add a method static void copyFile(String source, String destination) method that copies the source file to the destination location. For example, if called as copyFile(“a.txt”, “b.txt”) the contents of the file “a.txt” would be copied into the file “b.txt.”a. You must write the code to copy the file using java.io.* classes (e.g. File, FileInputStream, FileOutputStream, etc.).b. Do not assume that the files will contain only text.c. You should try to copy efficiently (i.e. not a single byte at a time).d. It is suggested that you test your method by copying the provided files from the input directory to the output directory in your project.e. The method should rethrow any exceptions that may occur.arrow_forwardWrite a program that will open the file dataFile.csv, read its contents and print them out. Your output should look like this: First Last Age Wagejane Smith 21.00 21.50Jack Jones 20.00 19.50Edgar Martinez 22.00 22.75Zanab Sayegh 21.00 21.75 Could I get help doing this code in python. I can't put the file here but I put a screenshot of it in the images below. If I'm missing more details let me know. Thanks.arrow_forward
- Part I Write a method that takes a celsius input from user and converts given value to other units of temperature, i.e. kelvin and fahrenheit. Part II Write a method that writes the given celsius input and its conversions to a file. Part III Write a method that reads the written temperature values from a file.arrow_forwardWrite a Java program that reads in a paragraph of text from a file and prompts the user to enter a word to search for. The program should then output the number of times the word appears in the paragraph. Here are the basic steps to implement this program: Prompt the user to enter the name of the input file. Read in the paragraph of text from the input file. Prompt the user to enter a word to search for. Search the paragraph for the word and count the number of times it appears. Output the number of times the word appears in the paragraph. To implement step 4, you can use a similar approach to the example I provided in class: Split the paragraph into an array of words using the split() method. Iterate through each word in the array and compare it to the search word (ignoring case). If the word matches the search word, increment a counter variable.arrow_forwardIn this assignment, you will create a Java program to read undergraduate and graduate students from an input file, sort them, and write them to an output file. This assignment is a follow up of assignment 5. Like assignment 5, your program will read from an input file and write to an output file. The input file name and the output file name are passed in as the first and second arguments at command line, respectively. Unlike assignment 5, the Student objects are sorted before they are written to the output file. • The program must implement a main class, three student classes (Student, UndergradStudent, GradStudent), and a Comparator class called StudentIDComparator. • The StudentIDComparator class must implement the java.util.Comparator interface, and override the compare() method. Since the Comparator interface is a generic interface, you must specify Student as the type parameter when defining the StudentIDComparator class, i.e., public class StudentIDComparator implements…arrow_forward
- Write a program to read the names in BoyNames.txt and GirNames.txt. Find the names that appear in both files and display them on screen. Girlname: Madison Emma Olivia Hannah Abigail Isabella Samantha Elizabeth Ashley Alexis Sarah Sophia Alyssa Grace Ava Taylor Brianna Lauren Chloe Natalie Kayla Jessica Anna Victoria Mia Hailey Sydney Jasmine Julia Morgan Destiny Rachel Ella Kaitlyn Megan Katherine Savannah Jennifer Alexandra Allison Haley Maria Kaylee Lily Makayla Brooke Mackenzie Nicole Addison Stephanie Lillian Andrea Zoe Faith Kimberly Madeline Alexa Katelyn Gabriella Gabrielle Trinity Amanda Kylie Mary Paige Riley Jenna Leah Sara Rebecca Michelle Sofia Vanessa Jordan Angelina Caroline Avery Audrey Evelyn Maya Claire Autumn Jocelyn Ariana Nevaeh Arianna Jada Bailey Brooklyn Aaliyah Amber Isabel Danielle Mariah Melanie Sierra Erin Molly Amelia Isabelle Madelyn Melissa Jacqueline Marissa Shelby Angela Leslie Katie Jade Catherine Diana Aubrey Mya Amy Briana Sophie Gabriela Breanna…arrow_forwardwrite java programarrow_forwardWrite a program that reads a file named input.txt and writes a file that contains the same contents, but is named output.txt. The input file will contain more than one line when I test this and so should your output file. Do not use a path name when opening these files. This means the files should be located in the top level folder of the project. This would be the folder that contains the src folder. Do not use a copy method that is supplied by Java. Your program must read the file line by line and write the file itself.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education