Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 12PP

(This is a variant of an exercise from Chapter 1.) Create a text file that contains the text " I hate programming!" Write a program that reads in this line of text from the file and then the text with the first occurrence of "hate" changed to " love". In this case, the program would output" l love programming!" Your program should work with any line of text that contains the word "hate", not just the example given in this problem. If the word "hate" occurs more than once in the line, your program should replace only the first occurrence of "hate".

Blurred answer
Students have asked these similar questions
For this program, assume you have an input file with several lines of text. Each line has a student's last name, followed by a space and then 4 numbers which represent his/her grades. Your program should read this input file and produce an output file with the same number of lines, each line showing the last name and the average of the student's scores. "grades.txt" is the file your program should read.  "badformat.txt" is an example of a file that your program can't read, so a clear error message should be generated, as shown in the sample output. Your program must catch all exceptions. Your main method must NOT have a "throws" clause - it must catch all exceptions and dea' with them appropriately. Other methods may throw exceptions, as long as the main method catches them. I don't expect you to examine any filenames to make sure they're valid. Instead, you should use the filename the user gives you and try to open a file by that name. That will throw an exception if the filename is…
Your program should use a loop to read data from a text file which contains students' names and 3 exam scores. The program should calculate the exam average for each student, determine the appropriate letter grade for that exam average, and print the name, average, and letter grade. After printing all this, you need to print the count of the total number of A's, B's, C's, D's, and F's for the whole class. The text file you need to use can be accessed using this link:   scores.txt.   Copy this file to the folder where your program will reside. The text file contains a list of 30 records, and each record contains a name and that person's 3 test scores. Each field is separated by a tab character. The first 2 records looks like this: Davis      88     92     84Wilson     98     80     73 and so on. Your program will need to open this file and read each line until the end of file. I recommend calculating a student's exam average and letter grade as you read the file, although this is not a…
Write a  program  that  reads  a  file  consisting  of  students’  test  scores  in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24,25–49,50–74, 75–99,100–124,125–149,150–174, and 175–200.  Output the score ranges and the number of students. (Run your program with the following input data: 76,89,150,135,200,76,12,100,150,28,178,189,167,200,175,150,87,99,129,149,176,200,87,35,157,189.)

Chapter 2 Solutions

Absolute Java (6th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License