Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7, Problem 7E
Define the following methods for the class Ledger, as described in the previous exercise:
- getAverageSale () —returns the average value of all the sales
- getCountAbove (v) —returns the number of sales that exceeded v in value
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Search for textbooks, step-by-step expl
= bartleby
e Q&A Library
Design a class nam
Start your trial
Design a class named MyPoint to represent a point with
X-and y-coordinates. The class contains:
The data fields x and y that represent the coordinates with getter methods.
A no-arg constructor that creates a point (0, 0).
A constructor that constructs a point with specified coordinates.
A method named distance that returns the distance from this point to a
specified point of the MyPoint type.
A method named distance that returns the distance from this point to
another point with specified x- and y-coordinates.
A static method named distance that returns the distance from two MyPoint
objects.
Draw the UML diagram for the class then implement the class. Write a test
program that creates the two points (0, 0) and (10, 30.5) and displays the distance
between them.
O16
W
MacR eok
Computer Science Question
Object Oriented Programming: 213COMP, 214COMP (Feb-2022)
Assignment- I [10 marks]
Academic honesty:
O Only pdf file accepted & student ID, will be your upload file.
O Student who submit copied work will obtain a mark of zero.
O Late work or attach file by email message not allowed.
Q1: Write the signature for a method that has one parameter of type String, and does
not return a value.
Q2: Write the signature for a method that has two parameters, both of type Student,
and returns an int value.
Q3: Write the constructor's headers of the followings?
new Student (202101156, “Ahmed");
new Address(51, "jazan university","CS&IT" );
new Grade(true, 505235600, 4.5);
Q4:
a) Write a class Student that define the following information:
name, stid , age.
b) Explain a mutators (setters) and accessors(getters) methods for each
attributes(fields).
c) Add three constructors:
• with empty constructor.
one parameter constructor (name of student)
two parameters constructor (name and stid)
d) Create two…
Chapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - Consider the following array: int [] a = new...Ch. 7.1 - What is wrong with the following code to...Ch. 7.1 - Write a complete Java program that reads 20 values...Ch. 7.2 - Write some Java code that will declare an array...Ch. 7.2 - Rewrite the method displayResults of the program...Ch. 7.2 - What output will be produced by the following...Ch. 7.2 - Give the definition of a static method called...
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Write the function htoi(s), which converts a suing of hexadecimal digits (including an optional 0x or 0X) into ...
C Programming Language
Search Benchmarks Modify the sequentialSearch and binarySearch methods presented in this chapter so they keep a...
Starting Out with Java: Early Objects (6th Edition)
Write a program that will search a file of numbers of type int and write the largest and the smallest numbers t...
Problem Solving with C++ (9th Edition)
Each of two robot arms is programmed to lift assemblies from a conveyor belt, test them for tolerances, and pla...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
When you write an if-else statement, under what circumstances do the statements that appear after the else clau...
Starting Out with Python (4th Edition)
Knowledge Booster
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
- //Todo write test cases for SimpleCalculator Class // No need to implement the actual Calculator class just write Test cases as per TDD. // you need to just write test cases no mocking // test should cover all methods from calculator and all scenarios, so a minimum of 5 test // 1 for add, 1 for subtract, 1 for multiply, 2 for divide (1 for normal division, 1 for division by 0) // make sure all these test cases fail public class CalculatorTest { //Declare variable here private Calculator calculator; //Add before each here //write test cases here }arrow_forwardAdd a removeLot method to the Auction class, having the -following header: /** * Remove the lot with the given lot number. * @param number The number of the lot to be removed. * @return The Lot with the given number, or null if * there is no such lot. */ public Lot removeLot(int number) This method should not assume that alot with a given number is stored at any particular location within the collection.arrow_forwardprivate float c; private void method2(double y) { c = y; } in another class we created an object of the first class then within in it : tester.method2 (10.0f); are there any errors ? how many errors if there are any and with explanation please.arrow_forward
- Java Programming: Write a static method named urgentAndIncomplete. Write the method as if it is in Main.java (not part of the ToDoItem class). The method should: Accept three ToDoItem references as parameters, and Return an int. Count how many of the ToDoItems meet two criteria: A priority greater than 3 Not completed The method should return how many of the parameters meet these criteria. That will be either 0, 1, 2, or 3.arrow_forwardFibonacci A fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers. For example: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on… For this, you will implement a class that takes a positive integer (n) and returns the number in the nth position in the sequence. Examples When n is 1, the returned value will be 0. When n is 4, the returned value will be 2. When n is 9, the returned value will be 21. come up with the formula and base cases Implementation Create a class Fibonacci with a public static method getValue. Create a Main class to test and run your Fibonacci class.arrow_forwardAbstract in Java Employee Override the display method in the Person class override the toString() and equals() methods Define method earnings as abstract with a return type of double. Hourly Employee provide the setters and getters of your data members provide call to parent contructors earnings is computed by having the product of the total number of hours worked and the rate. but if the number of hours worked exceeds 40, the rate increases to 150% of the current rate. (ex. rate=200; 150% = 300) override the toString() and equals() methods Note:Class Person is already loaded in this activity. No need to add the class in your code.arrow_forward
- Write in python language thank youarrow_forwardPlease solve it with Javaarrow_forwardIn Java Write a class definition for a Rectangle class that contains:• Two int fields, length and width.• Mutator and accessor methods for the length and width fields.• A Boolean method named isSquare that returns true if the rectangle’s lengthand width are the same and false otherwise.b) Write a class definition for a RectangleDriver class that contains a main methodthat acts as a driver for the Rectangle class of the previous problem. The main methodshould do this:• Construct a Rectangle object named rect.• Use the mutator methods to assign arbitrary values to rect’s length and widthfields.• Use the Boolean method to determine if rect is a square.-- If rect is a square, print “Square: ” and then the square’s dimensions.For example: Square: 4x4.-- If rect is not a square, print “Rectangle: ” and then the rectangle’sdimensions. For example: Rectangle: 6x13.• In printing the above messages, use the accessor methods to retrieve therectangle’s dimensionsarrow_forward
- Finish the TestPlane class that contains a main method that instantiates at least two Planes. Add instructions to instantiate your favorite plane and invoke each of the methods with a variety of parameter values to test each option within each method. To be able to test the functionality of each phase, you will add instructions to the main method in each phase.arrow_forwardpublic float method1(int z) { return (float) z; } // in another class we created an object of the first class and within in it: int y = tester.method1(); are there any errors ? with explanation pleasearrow_forward3. Write a class Student having attributes to store the following data: Name, fathers’ Name, department, degree, enrolment, seat number, marks of three subjects. Also write a class to test all methods of Student class. Add the following methods in the above class. • int getTotal() : This methods returns the total of marks • void printTotal() Prints the total marks of Student • float getPercentage() this method calculates the percentage of a student • void printPercentatge() this method prints the percentage of student • char getGrade() this method calculates and returns the grade. • void printGrade() this method prints the grade of a student. • void printInfo() This method prints all information of the student.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY