What should line number 24 be? The aim is to read the first line from the file MyName.txt and display it. Enter the entire line 24 i.e. String str = 20 File file = new 21 Scanner inputFile = new Scanner(file); 22 if (inputFile.hasNext()) 23 { 24 String str =- 25 System.out.println(str); 26 } 27
Q: Create a program that will ask the user to enter a string Your task is replace the elements in the…
A: Hello Student. Warm welcome from my side. Hope you are doing great. I will try my best to answer…
Q: 1. What is wrong with the following condition? Correct it. if (grade > 70 || grade <= 80)
A: Conditions in java are used to pass through certain conditions.
Q: Clickzone Copy Center charges Php 15 for the first 10 copies, plus 0.75 per copy for the next 10…
A: The program is written in java import java.util.*;public class Main{ public static void…
Q: 2. Create a program that will display the following output using for(), while() and do-while()…
A: Import the java utility In main Class declare the variables m and n Get the m and n value from the…
Q: If class Apple extends class Fruit, which of the following is also true? O Fruit is the super class…
A: Correct Answer: - All of the above For Fruit is the super class of Apple It is correct because…
Q: You run four computer labs. Each lab contains computer stations that are numbered as shown in the…
A: JAVA PROGRAM: //Import the required package.import java.util.*; //Define the class.public class LAB…
Q: 1. Write a nested loop that displays 15 rows of '*' characters. There should be 30.'*' characters in…
A: As per the requirement program first program is developed. Note: As per our guidelines we are…
Q: Input: Operation to be made N number of inputs based on the operation Output: The calculator should…
A: First print all the menus. Read the choice of user and store in a character variable. If choice is…
Q: Software Requirements: Latest version of NetBeans IDE • Java Development Kit (JDK) 8 Procedure: 1.…
A: Program: import java.util.*;import java.io.*; public class Main{ public static void main(String[]…
Q: Draw a flowchart to sum the even numbers between 0 and 59.
A: Initialize a variable sum to zero.Iterate through numbers from 0 to 59.For each number, check if it…
Q: 1. Create a program that will display the following output using for(), while() and do-while()…
A: public class pattern { public static void main(String[] args) // main function {…
Q: Construct a class named TestCirde whose main() method dedares THREE (3) Cirde objects. Using the…
A:
Q: Write an application that catches and throws an ArithmeticException when you attempt to take the…
A:
Q: Create a program that will compute for the area and perimeter of a rectangle using classes. You must…
A: length and width will be the variables of Rectangle class getArea() and getPerimeter() will be the…
Q: 15.7 (Telephone-Number Word Generator) Standard telephone keypads contain the digits zero through…
A: Introduction Inheritance: Inheritance is a crucial OOP concept (Object-Oriented Programming). The…
Q: Question Print Daily Company (PDC) needs a program that displays weekly salary. PDC has five…
A: Code with the OOP approach in JAVA is given below along with output
Q: Create a program that will ask the user to enter the elements of a 3 x 4 matrix. Your task is to…
A: Algorithm: Start Read a 3×4 matrix 'a' Initialize sum to 0 and count to 0 Iterate through the…
Q: The lucky number is the sequence number generated by the filter algorithm: if the number in the…
A: Step 1: Generate a list from 1 to size. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,…
Q: Write an application that displays the multiplication table for numbers from 1 to 9. The table…
A: Java code: public class Main { //class public static void main(String[] args) { //main…
Q: Java programming
A: Program: //import the header file import java.util.Scanner; import java.text.DecimalFormat;…
Q: 10.14 (Project: Shape Hierarchy) Implement the Shape hierarchy shown in Fig. 9.3. Each Two-…
A: Solution: Given,
Q: Every cylinder has a base and height, where the base is a circle. Design the class Cylinder that can…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid, as…
A: import java.util.*;import java.lang.*;import java.io.*; class Codechef{ public static void main…
Q: In this chapter, the class Date was designed to implement the date in a program, but the method…
A: /* Java program to test class */ public class Date { // Instance variables int day;…
Q: Every circle has a center and a radius. Given the radius, we can determine the circle's area and…
A: public class Point{ double x, y;public Point(){setPoint( 0, 0 );}public Point(double x, double y…
Q: Write a method with the following header that returns a pentagonal number: public static int…
A: The nth pentagonal number pn is given by the formula: pn = (3n2 - n) / 2 for n >= 1.
Q: Implement a program that can input an expression in postfix notation (see Exer- cise C-6.19) and…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: FOR ALL PARTS, MAKE SURE YOUR METHODS ARE STATIC O PART 1: Method with Output O Define a method…
A: class MethodPractice{ public static void printHelloworld() {…
Q: Given the following: public class Beta extends Alpha{ Java syntax requires class Beta to have a…
A: False
Q: Write a method LinkedList joinLists (LinkedList list1, LinkedList list2) to join two linked lists…
A: Solution: Java code: import java.util.*; public class Test { /** * This method take two…
Q: Create a folder named LastName_FirstName in your local drive. (ex. Reyes_Mark) Using NetBeans,…
A: The program is written in Java. Please find the source code and output in the below steps.
Q: In this exercise, you will design various classes and write a program to computerize the billing…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: 14.13 (Tokenizing and Comparing Strings) Write an application that reads a line of text, tokeniz- es…
A: Code Sample Output
java
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- JAVA PPROGRAM Write a program that prompts the user to enter a file name, then opens the file in text mode and reads names. The file contains one name on each line. The program then compares each name with the name that is at the end of the file in a symmetrical position. For example if the file contains 10 names, the name #1 is compared with name #10, name #2 is compared with name #9, and so on. If you find matches you should print the name and the line numbers where the match was found. While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name. The file may contain up to 100 names. You can use an array or ArrayList object of your choosing, however you can only have one array or ArrayList. Input validation: a) If the file does not exist, then you should display a message "File 'somefile.txt' is not found." and allow the…FILE* inFile = fopen("filenam.txt", "r"); Given the above code segment, which of the following would output "FILE NOT FOUND" if the file could not be opened? Group of answer choices if(inFile == NULL) { printf("FILE NOT FOUND"); } if(inFile) { printf("FILE NOT FOUND"); } if(!inFile->is_open()) { printf("FILE NOT FOUND"); } None of these ============= What does sscanf do? Group of answer choices Reads from a file Reads from a keyboard Reads from a string Writes to a screen =========== What comes first in the software development life cycle? Group of answer choices Algorithm design Identifying the problem Coding TestingBASH FLOW CHART: Create a flow chart to describe an algorithm that takes a text file with format ID,FirstName,Last Name,Street,City and appends a user ID field consisting of a C followed by theemployee ID. For example, the first entries in Lab 2's employees.txt are:0,Douglas L,Eberhard,Addenda Circle,Cornwall1,Elizabeth Sua,Hemauer,Wyatt Way,Peterborough2,Bailey Rae,Lopez,Turnagain Street,Sault Ste. MarieAfter processing, the entries should be:0,Douglas L,Eberhard,Addenda Circle,Cornwall,C01,Elizabeth Sua,Hemauer,Wyatt Way,Peterborough,C12,Bailey Rae,Lopez,Turnagain Street,Sault Ste. Marie,C2
- Task: Loading data from files This exercise will require you to load some information from files and use it in your program. scene.txt contains a description of a series of shapes and colours to draw. You need to write code to read in the file data and draw the requested shapes in the correct colour. Each line in scene.txt will contain one of the following starting keywords followed by some data: COLOUR followed by 3 values: R, G, B CIRCLE followed by 3 values: X, Y, RADIUS RECT Followed by 4 values: X, Y, W, H LINE Followed by 4 values: X1, Y1, X2, Y2 CIRCLES are defined from the center. RECT's are defined from the top left. All values are space separated, and you can assume all input is correct (no errors). Please solve this program to draw the scene. I can't upload the file scene.txt, so I decide to screenshot a file for you. Subject: Java ProgrammingThe Info.txt file contains the statement This is a file which stores some information. What is the output of the following code snippet? int main() { } ifstream read_file; read_file.open("Info.txt"); string linel; string line2; read_file >> linel; get line (read_file, line2); cout << linel << endl; cout << line2 << endl; return 0; This is a file which stores some information This is a file which stores some information This is a file which stores some information This is a file which stores some information There is no output because the code snippet does not compile.Creat a text file and run the code to display.(on each text file) Sample lab2_codeBook_input.txt sample lab2_decrypted.txt[0,2] aba aa[2,4,1] bcasa aac[2,1,5,0] retire teer[2,1,5,7] retire None
- >> classicVinyls.cpp For the following program, you will use the text file called “vinyls.txt” attached to this assignment. The file stores information about a collection of classic vinyls. The records in the file are like the ones on the following sample: Led_Zeppelin Led_Zeppelin 1969 1000.00 The_Prettiest_Star David_Bowie 1973 2000.00 Speedway Elvis_Presley 1968 5000.00 Spirit_in_the_Night Bruce_Springsteen 1973 5000.00 … Write a declaration for a structure named vinylRec that is to be used to store the records for the classic collection system. The fields in the record should include a title (string), an artist (string), the yearReleased (int), and an estimatedPrice(double). Create the following…need help debugging thisJAVA PPROGRAM ASAP Hypergrade does not like this program because it says 2 out of 7 passed and take out the extra \n from the program. Please Modify and change this program ASAP BECAUSE IT IS HOMEWORK ASSIGNMENT so it passes all the test cases. The program must pass the test case when uploaded to Hypergrade. Also, for test cases 1-4 it wants only to input Please enter the file name or type QUIT to exit: then input the file and display the Total number of words. For test cases 5 and 7 it wants to only to input Please enter the file name or type QUIT to exit then input input5.txt and then display File: input5.txt does not exist.\n then display Please enter the file name again or type QUIT to exit:\n then type input1.txt to display the total number of words or type quit to exit the program. For test case 6 it wants only to Please enter the file name again or type QUIT to exit:\n then type quit to exit the porgram. import java.io.File;import java.io.FileNotFoundException;import…
- PROGRAM NEEDS TO MATCH EXAMPLE PHOTO Write a program ( lab6.cpp ) that gives and takes advice on program writing. The program starts by writing a piece of advice to the screen and asking the user to type in a different piece of advice. The program then ends. The next person to run the program receives the advice given by the person who last ran the program. The advice is kept in a file, and the contents of the file change after each run of the program. You can use your editor to enter the initial piece of advice in the file so that the first person who runs the program receives some advice. Allow the user to type in advice of any length so that it can be any number of lines long. The user is told to end his or her advice by pressing the Return key two times. Your program can then test to see that it has reached the end of the input by checking to see when it reads two consecutive occurrences of the character ‘\n’. Hints:- You need to look at each character as it is read to see if it is…A Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned, heart rate, sleeping patterns, and so on. One common physical activity that most of these devices track is the number of steps you take each day. The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and each line contains the number of steps taken during a day. (The first line is the number of steps taken on January 1st, the second line is the number of steps taken on January 2nd, and so forth.) Write a program that reads the file, then displays the average number of steps taken for each month. (The data is from a year that was not a leap year, so February has 28 days.) You don't need to see the file , Just write a code using the "file" like this def main(): with open("steps.txt", "r") as file:IN PYTHON LANGUAGE