Java: An Introduction to Problem Solving and Programming (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 10, Problem 5E

Modify the class LapTimer, as described in Exercise 13 of Chapter 9, as follows:

  • Add an attribute for a file stream to which we can write the times
  • Add a constructor

LapTimer (n, person, fileName)

for a race having n laps. The name of the person and the file to record the times are passed to the constructor as strings. The file should be opened and the name of the person should be written to the file. If the file cannot be opened, throw an exception.

Blurred answer
Students have asked these similar questions
Put the client program in a separate file from the class, and divide the class into specification file (fraction.h) and implementation file (fraction.cpp), so your code will be in 3 separate files. Fraction.h #include <iostream>using namespace std; int gcd(int a, int b) { if (a == 0) return b; if (b == 0) return a;  if (a == b) return a;  if (a > b)  return gcd(a - b, b); return gcd(a, b - a);} class Fraction {private: // numerator and denominator int n, d; public: // simplifies the fraction void simplify() {  int g = gcd(n, d);  n /= g;  d /= g; } // default constructor Fraction() {  n = 0, d = 1; } // parameterised constructor Fraction(int a, int b) {  n = a, d = b;  simplify(); }  // prints the fration as n/d void print() const {  cout << n << "/" << d; }  // multiplies 2 fractions and returns it Fraction multipliedBy(Fraction f) const {  f.simplify();  Fraction r;  r.n = n * f.n;  r.d = d * f.d;  r.simplify();  return r; }  // divides two fraction and…
Write a program in Java to perform the following: Using a BufferedReader class and related objects, read a string object consists of 60 words plus some special characters and numbers. Include double space between some words. Include a few $ and % signs in your text. Store that text into a file using proper classes and methods. Call that file fileon.doc which will be your input file then read the contents of that file and perform the following operations using java available methods: Add a new line at the beginning of the text to include your name and the class name (csc 202) Find the length of you text Change the first character of each line to upper case . Find the number and location of all $ sign and re place it with a space. Delete all double spaces Calculate the number of special characters Find the number of lines in your text. Remember each line is terminated by a “.”, find the number of vowel in the last line Count the number of digits in your text. Append a new line consist…
Write a C++ program: Make a class for rectangle which calculates perimeter and area. then write two programs(.cpp files). one program has two objects that each of them is a Square and you ask user to give you the side. and in other program you have two rectangle objects and you ask user to give you length and width. then by using the class you defind in seperate file, claculate area and primiter. in each program you have the following: use the dynamic allocation. has a default constructor has a destructor. use an array of objects for 2 different rectangles make a UML you have to upload 3 files as submissions for this assignment. (or you can submit a link to an online compiler such as "replit" that includes all these 3 files) class (.h) (just one) main function (.cpp)  (two)  UML (one)

Chapter 10 Solutions

Java: An Introduction to Problem Solving and Programming (7th Edition)

Ch. 10.3 - Prob. 11STQCh. 10.4 - Write some Java code to create an output stream of...Ch. 10.4 - Give three statements that will write the values...Ch. 10.4 - Give a statement that will close the stream toFile...Ch. 10.4 - What import statement(s) do you use when creating...Ch. 10.4 - Prob. 16STQCh. 10.4 - Give three statements that will read three numbers...Ch. 10.4 - Give a statement that will close the stream...Ch. 10.4 - Can you use writeInt to write a number to a file...Ch. 10.4 - Can you use readUTF to read a string from a text...Ch. 10.4 - Prob. 21STQCh. 10.4 - Prob. 22STQCh. 10.4 - Does the class FileInputStream have a method named...Ch. 10.4 - Does the class FileOutputStream have a constructor...Ch. 10.4 - Does the class ObjectOutputStream have a...Ch. 10.4 - Prob. 26STQCh. 10.4 - Suppose that a binary file contains exactly three...Ch. 10.4 - The following code appears in the program in...Ch. 10.4 - Prob. 29STQCh. 10.5 - Prob. 30STQCh. 10.5 - Prob. 31STQCh. 10.5 - Prob. 32STQCh. 10.5 - Prob. 33STQCh. 10.6 - Prob. 34STQCh. 10.6 - Prob. 35STQCh. 10.6 - Prob. 36STQCh. 10.6 - Prob. 37STQCh. 10 - Write a program that will write the Gettysburg...Ch. 10 - Modify the program in the previous exercise so...Ch. 10 - Write some code that asks the user to enter either...Ch. 10 - Write a program that will record the purchases...Ch. 10 - Modify the class LapTimer, as described in...Ch. 10 - Write a class TelephoneNumber that will hold a...Ch. 10 - Write a class contactInfo to store contact...Ch. 10 - Write a program that reads every line in a text...Ch. 10 - Repeat the previous exercise, but write the new...Ch. 10 - Write a program that will make a copy of a text...Ch. 10 - Suppose you are given a text file that contains...Ch. 10 - Suppose that you have a binary file that contains...Ch. 10 - Suppose that we want to store digitized audio...Ch. 10 - Write a program RecoverSignal that will read the...Ch. 10 - Even though a binary file is not a text file, it...Ch. 10 - Write a program that searches a file of numbers...Ch. 10 - Write a program that reads a file of numbers of...Ch. 10 - The following is an old word puzzle: Name a common...Ch. 10 - The Social Security Administration maintains an...Ch. 10 - The following is a list of scores for a game....Ch. 10 - Write a program that checks a text file for...Ch. 10 - Prob. 5PPCh. 10 - Prob. 6PPCh. 10 - Revise the class Pet, as shown in Listing 6.1 of...Ch. 10 - Write a program that reads records of type Pet...Ch. 10 - Prob. 9PPCh. 10 - Prob. 12PPCh. 10 - Prob. 15PP

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY