Java: Introduction to Problem Solving and Programming
Java: Introduction to Problem Solving and Programming
7th Edition
ISBN: 9780133834604
Author: SAVITCH
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 7, Problem 6E

Create a class Ledger that will record the sales for a store. It will have the attributes

  • sale—an array of double values that are the amounts of all sales
  • salesMade —the number of sales so far
  • maxSales—the maximum number of sales that can be recorded and the following methods:
  • Ledger (max) —a constructor that sets the maximum number of sales to max
  • addSale (d) —adds a sale whose value is d
  • getNumberOfsales —returns the number of sales made
  • getTotalSales—returns the total value of the sales
Blurred answer
Students have asked these similar questions
When you add a contact to your phone, it automatically sorts those names alphabetically. In this exercise, we are going to create a phonebook that automatically sorts everytime a new number is added to the phonebook. A PhoneNumber class has been created already that has the instance variables name and number. Your job is to create the PhoneBook class that will store an ArrayList of PhoneNumbers. The PhoneBook class does not have a constructor - it only contains an ArrayList that can store the individual phone numbers that are added to it. There should be three methods in the PhoneBook class: addNumber- This method takes a PhoneNumber and adds it to the directory. Once the number has been added, the sort method is called on the directory to sort that new address into the phone book. sort- This method sorts the directory in alphabetical order A-Z.a. Remember that in order to compare Strings, we can use the compareTo() method. This returns an integer that indicates whether a String’s…
Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly.  An appointment has a description (for example, “see the dentist”) and a date (use int's to store the date).  Write a method occursOn(int year, int month, int day) that checks whether the appointment occurs on that date.  For example, for a monthly appointment, you must check whether the day of the month matches.  Additionally, you will need to implement a class called Calendar.  This will contain an ArrayList of Appointment objects (The list is an instance variable of the Calendar class).  You will need to provide the following methods for your Calendar class.   A no argument constructor   public Calendar(){...}   This constructor will initialize your ArrayList instance variable to an empty list.   /** * A method to add an appointment to the calendar * @param apt – the appointment object to add to the calendar. */ public void add(Appointment apt) {…}   /** * A method to remove an appointment from the…
Complete the Course class by implementing the findStudentHighestGpa() method, which returns the Student object with the highest GPA in the course. Assume that no two students have the same highest GPA. Given classes: Class Course represents a course, which contains an ArrayList of Student objects as a course roster. (Type your code in here.) Class Student represents a classroom student, which has three private fields: first name, last name, and GPA. (Hint: GetGPA() returns a student's GPA.) Ex: If the following students and their GPA values are added to a course: Henry Nguyen with 3.5 GPABrenda Stern with 2.0 GPALynda Robison with 3.2 GPASonya King with 3.9 GPA then the findHighestStudent() method returns a student and the program output is: Top student: Sonya King (GPA: 3.9)Code:Course.java: import java.util.ArrayList; //create class Student //create class Courseclass Courses{    private ArrayList<Student> roster; // collection of Student object        //  class constructor…

Chapter 7 Solutions

Java: Introduction to Problem Solving and Programming

Ch. 7.2 - Give the definition of a static method called...Ch. 7.2 - Prob. 12STQCh. 7.2 - The following method compiles and executes but...Ch. 7.2 - Suppose that we add the following method to the...Ch. 7.3 - Prob. 15STQCh. 7.3 - Replace the last loop in Listing 7.8 with a loop...Ch. 7.3 - Suppose a is an array of values of type double....Ch. 7.3 - Suppose a is an array of values of type double...Ch. 7.3 - Prob. 19STQCh. 7.3 - Consider the partially filled array a from...Ch. 7.3 - Repeat the previous question, but this time assume...Ch. 7.3 - Write an accessor method getEntryArray for the...Ch. 7.4 - Prob. 23STQCh. 7.4 - Write the invocation of the method selectionSort...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - Consider an array b of int values in which a value...Ch. 7.5 - What output is produced by the following code?...Ch. 7.5 - Revise the method showTable in Listing 7.13 so...Ch. 7.5 - Write code that will fill the following array a...Ch. 7.5 - Write a void method called display such that the...Ch. 7.6 - Prob. 33STQCh. 7 - Write a program in a class NumberAboveAverage that...Ch. 7 - Write a program in a class CountFamiles that...Ch. 7 - Write a program in a class CountPoor that counts...Ch. 7 - Write a program in a class FlowerCounter that...Ch. 7 - Write a program in a class characterFrequency that...Ch. 7 - Create a class Ledger that will record the sales...Ch. 7 - Define the following methods for the class Ledger,...Ch. 7 - Write a static method isStrictlyIncreasing (double...Ch. 7 - Write a static method removeDuplicates(Character[]...Ch. 7 - Write a static method remove {int v, int [] in}...Ch. 7 - Suppose that we are selling boxes of candy for a...Ch. 7 - Create a class polynomial that is used to evaluate...Ch. 7 - Write a method beyond LastEntry (position) for the...Ch. 7 - Revise the class OneWayNoRepeatsList, as given in...Ch. 7 - Write a static method for selection sort that will...Ch. 7 - Overload the method selectionSort in Listing 7.10...Ch. 7 - Revise the method selectionSort that appears in...Ch. 7 - Prob. 18ECh. 7 - Write a sequential search of an array of integers,...Ch. 7 - Write a static method findFigure (picture,...Ch. 7 - Write a static method blur (double [] [] picture)...Ch. 7 - Write a program that reads integers, one per line,...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - Write the method rotateRight that takes an array...Ch. 7 - The following code creates a ragged 2D array. The...Ch. 7 - Write a program that will read a line of text that...Ch. 7 - Prob. 2PPCh. 7 - Add a method bubbleSort to the class ArraySorter,...Ch. 7 - Add a method insertionSort to the class...Ch. 7 - The class TimeBook in Listing 7.14 is not really...Ch. 7 - Define a class called TicTacToe. An object of type...Ch. 7 - Repeat Programming Project 10 from Chapter 5 but...Ch. 7 - Prob. 8PPCh. 7 - Write a GUI application that displays a picture of...Ch. 7 - ELIZA was a program written in 1966 that parodied...Ch. 7 - Prob. 11PPCh. 7 - Create a GUI application that draws the following...Ch. 7 - Practice Program 2 used two arrays to implement a...Ch. 7 - Practice Program 5.4 asked you to define Trivia...
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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY