Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Please written by computer source
java)
13)
Assume the class Cylinder exists, and that has the following method. Assume both radius and height are global instance variables declared as double.
public double calcVolume() { return Math.PI * radius * radius * height; }
You decide that a static method (also called calcVolume) for calculating volume (of a theoretical cylinder) might be useful to client coders.
Write the static method.
Then rewrite the instance method shown above to leverage the new static method (thus reducing code duplication).
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 1 images
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
- Java Instance data:Variable mpg for fuel efficiency (miles per gallon = mpg)Variable gas to save how many gallons of gas left in the tank Constructors:Default constructor with no parameter. Use 0 as initial values.Overloaded constructor with two parameters Methods:getMPG() & setMPG()(getGas() & setGas()toString() methoddrive() to simulate that the car is driven for certain miles. For example, v1.drive(100) means vehicle v1 is driven 100 miles. You need to calculate the gas cost and update the gas tank: gas = gas - miles/mpg. You also need to check if there is enough gas left since gas should not be negative. You need to figure out the formal parameters for the above methods. In the testing class, prompt the user for information to create two objects of the Vehicle class. Let each vehicle drive 200 miles. Print out the left gas for each vehicle. Ex: Vehicle 1 Enter the mpg: 40 Enter the gas left: 10.5 Vehicle 2 Enter the mpg: 35 Enter the gas left: 2.1 Vehicle 1…arrow_forwardCan you help me solve it in Visual Basic language?in consol VBarrow_forwardProblem: Develop a class encapsulating the concept of a college course, assuming that a course has followingattributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include aconstructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test thebehavior of the class and its methods. The outline of the class is given as follows: public class Course {private String course;private String description;private int credits;private int maxStudents;public Course( ) { }public Course (String course, String desc, int credits, int maxNum ) { }public String getCourse ( ) { }public void setCourse ( String c ) { }public String getDescription ( ) { }public void setDescription ( String desc ) { }public int getCredits ( ) { }public void setCredits ( int cred ) { }public int getStudents ( ) { }public void setStudents ( int students ) { }public String toString ( ) { }public boolean equals ( Object obj ) { }public…arrow_forward
- {In Java Programming Please} Create a class hierarchy that represents different types of employees in a company. Start with a class called Employee that has two methods: calculateSalary() and displayDetails(). Then, create two subclasses of Employee: Manager and Engineer. Override the calculateSalary() method in both subclasses to calculate the salary based on their job role and experience. Override the displayDetails() method in both subclasses to print out a message indicating the details of the employee. Next, create another class called Salesperson that extends Employee and has a method called calculateCommission(). Create two subclasses of Salesperson: SeniorSalesperson and JuniorSalesperson. Override the calculateCommission() method in both subclasses to calculate the commission based on their sales performance. Override the displayDetails() method in both subclasses to print out a message indicating the details of the salesperson. In the main method, create objects of each class…arrow_forwardIn C#, how would you write (2) programmer defined methods as described below: Method #1 (GreetingGeneric) — a type void programmer defined method does not require any parameters. It should output a generic greeting line for a letter. For example: "Dear Customer", "Dear Student", etc. Method #2 (GradeMessage) — a type void programmer defined method that has (3) parameters; (string, string, double) for (name, assignment, and grade) and should output the passed parameters in sentence format: GradeMessage("Jimmy", "Midterm Exam", 79.5) would output: Jimmy took the Midterm Exam and got 79.5 points. The Main() method for this program should: call Method #1 to output the generic greeting ask the user to enter a name, assignment, and grade and pass them to Method #2 for output. Input should only be done in the Main() method and output in the programmer-defined methods.arrow_forwardUsing python: (see attached- I need help with part Q2) Add a method to the person class name it (username) that takes the email and take off all the part from @ and after, and assigns the string before the @ sign to a variable username. For example: malabdullah@UT.edu, the method will assign 'malabdullah' as the username.arrow_forward
- Define the missing method. Use "this' to distinguish the local member from the parameter name. // ===== Code from file CablePlan.java public class CablePlan { private int numDays; // FIXME: Define setNumDays () method, using "this" implicit parameter. public void setNumDays (int numDays) { /* Your solution goes here */ } public int getNumDays () { return numDays; } // ==== end // ===== Code from file CallCablePlan.java import java.util.Scanner; public class CallCablePlan { public static void main (String [] args) { Scanner scnr = new Scanner (System.in); new CablePlan (); CablePlan houselPlan int userNum; scnr.nextInt (); houselPlan.setNumDays (userNum); System.out.println (houselPlan.getNumDays ()); userNum = // ===== end ==== =arrow_forward// IMPORT LIBRARY PACKAGES NEEDED BY YOUR PROGRAMimport java.util.List;// SOME CLASSES WITHIN A PACKAGE MAY BE RESTRICTED// DEFINE ANY CLASS AND METHOD NEEDED// CLASS BEGINS, THIS CLASS IS REQUIREDclass Solution{ // METHOD SIGNATURE BEGINS, THIS METHOD IS REQUIREDint itemPairs(int num, List<Integer> itemValues, int target) {// WRITE YOUR CODE HERE}// METHOD SIGNATURE ENDS}arrow_forwardPlease answer question. This is pertaining to Java programming language 3-20arrow_forward
- In Java code: Write the class encapsulating the concept of money, assuming that money has the following attributes: dollars, cents In addition to the constructors, the accessors and mutators, write the following methods: public Money() public Money(int dollars, int cents) public Money add(Money m) public Money substract(Money m) public Money multiply(int m) public static Money[] multiply(Money[] moneys, int amt) public boolean equals(Money money) public String toString() private void normalize() // normalize dollars and cents field Add additional helper methods if necessary. Use the following test driver program to test your Money class: public class MoneyTester{public static void main(String[] args){Money m1 = new Money(8, 75); // set dollars to 8 and cents to 75Money m2 = new Money(5, 80); // set dollars to 5 and cents to 80 MoneyMoney m3 = new Money(); // initialize dollars to 0 and cents to 0System.out.println("\tJane Doe " + "CIS35A Spring 2021 Lab 4"); // useyour…arrow_forward// interface method ==================================================public boolean isFullBT() {/*See BST.java for method specification *//* Hint: How can you "break-up" the problem into smaller pieces? *//* Your code here */return false; // Dummy return statement. Remove when you implement!} IN JAVA LANGUAGE RETURN TRUE IF BST IS A COMPLETE BST RETURN FALSE IS BST IS NOT A COMPLETE BST ALL INFO IN PICTURES PLS AND THANK YOU!!!!!arrow_forwardpublic class utils { * Modify the method below. The method below, myMethod, will be called from a testing function in VPL. * write one line of Java code inside the method that adds one string * to another. It will look something like this: * Assume that 1. String theInput is 2. string mystring is ceorge неllo, пу nane is * we want to update mystring so that it is неllo, пу nane is Ceorge */ public static string mymethod(string theInput){ System.out.println("This method combines two strings."); Systen.out.println("we combined two strings to make mystring); return mystring;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