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
A. Write static methods:
• public static double cubeVolume(double h) : h!
• public static double cubeSurface(double h) : 6h"
• public static double cylinderVolume(double r, double h) : h??"
• public static double cylinderSurface(double r, double h) : 2??h + 2??"
that compute the volume and surface area of a cube with height h, and a cylinder with circular base with radius r and height h. Place them into a class named “Geometry.java”. Then write a program with main class called here.java” that prompts the user for the values of r and h, calls the four methods, and prints the results.
B.ReconsideryourprevioussolutionbyimplementingclassesCube,and Cylinder separately instead of a single class “Geometry” (part A). Which approach is more object-oriented?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 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
- The weight of an object can be described by two integers: pounds and ounces (where 16 ounces equals one pound). Class model is as follows: public class Weight { private int pounds; private int ounces; public Weight(int p, int o) ( pounds=p+o/16: ounces = 0% 16: } Implement a method called subtract, which subtracts one weight to another. i.e. Weight w1 = new Weight(10.5): Weight w2 = new Weight(5.7): Weight w3= w1.subtract(w2):arrow_forwardWrite a program called AveMethod (main method) that contains a method called threeAve (method name) that computes the average of three numbers. a) The main method will do the following: • asks the user for 3 number (double type). • calls the threeAve method• print the average of the three numbersb) The threeAve method will do the following: • receives 3 numbers (parameters)• calculate the average of the three numbers• returns the average Sample Run: Input the first number: 2.5Input the second number: 3.5Input the third number: 6.6The average is 4.2arrow_forwarda Java program that defines and uses 3 overloaded methods (the Java file nameshould be “MethodOverload.java” and all the 3 methods should have the same methodname max). The 3 method headers are given below with their definitions:• int max(int n1, int n2, int n3):o to return the maximum of the passed 3 integer arguments.• double max(double d1, double d2, double d3):o to return the maximum of the passed 3 double arguments with use ofMath.max() method—that is, do not use if or if-else statement incomparing the numbers to find the smaller/smallest numbers.• int max(int n):In the main method of the application, a loop with switch-statement inside is required fortesting the different method calls and you need to generate random numbers for the inputsas the arguments for the methods (except for die-rolling case where an input is enteredfrom the keyboard.). Specifically:• int max(int n1, int n2, int n3): the 3 random integers should be from the sequence2, 5, 8, 11, 14.• double max(double d1,…arrow_forward
- can you solve this ?arrow_forwardWrite a method (with a parameter n), n: integer type that prints numbers from 1 to n. The print out should be 5 numbers per line. All the output numbers should be aligned well. Call the method with n=13 and n=10 in the main()arrow_forwardConsider a class that keeps track of the sales of an item. An object of this class will have the attributes Number sold Total sales Total discounts Cost per item Bulk quantity Bulk discount percentage and the following methods: registerSale(n) records the sale of n items. If n is larger than the bulkquantity, the cost per item will be reduced by the bulk discount. displaySales displays the number sold, the total sales, and total discount. Implement the class in Java. Write some Java statements that test the class.arrow_forward
- Write a Java method that computes the future investment value at a given interest rate for a specified number of years. Your method should return the future investment value after calculation. The future investment is determined using the formula below: futurelnvestmentValue = investmentAmount * (1+monthlylnterestRate)numberOfYears*12 You can use the following method header: public static double futurelnvestmentValue (double investmentAmount, double monthlylnterestRate, int years);arrow_forwardDefine a method printDate, with int parameters year and day, and String parameter month, that prints using Gregorian "Month DD, YYYY" format. For example, printDate (2020, 21, "October") prints October 21, 2020. Write the code of the method in the box below.arrow_forwardGiven main(), define the Team class (in file Team.java). For class method getWinPercentage(), the formula is:wins / (wins + losses). Note: Use casting to prevent integer division. For class method printStanding(), output the win percentage of the team with two digits after the decimal point and whether the team has a winning or losing average. A team has a winning average if the win percentage is 0.5 or greater. Ex: If the input is: Ravens 13 3 where Ravens is the team's name, 13 is the number of team wins, and 3 is the number of team losses, the output is: Win percentage: 0.81 Congratulations, Team Ravens has a winning average! Ex: If the input is: Angels 80 82 the output is: Win percentage: 0.49 Team Angels has a losing average.arrow_forward
arrow_back_ios
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