Thank you!
Base on all the methods 1-4, I want to write another method:
The spec for method 5
A method to print a text-based histogram
-
takes one parameter, an array of integers
-
no return value
Image 1 is the example of the expected output
Hint: it bacsically means: for example, if I have number 20 appears one time in my method, then we print a star(*) after number 20. I think we can use this method 4 to get this information.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
Thank you base on this question I want to write one more method.
The spec for this method is
write a method to print out the Mode
for example, in ur
plz provide a screenshot of your code when it's finished.
Thanks!
Thanks!
base one your
plz provide a screenshot of your code when u done
Thank you base on this question I want to write one more method.
The spec for this method is
write a method to print out the Mode
for example, in ur
plz provide a screenshot of your code when it's finished.
Thanks!
Thanks!
base one your
plz provide a screenshot of your code when u done
- Add another public method dblValue() to your Fraction class which returns the double precision approximation value of the fraction. That is, the floating point result of actually dividing numerator by denominator. N.B. this method does not do any display itself, but can be called by a client program to be used in an output statement. Eg: if a client has a fraction frac that represents 1 / 2, then a method call to frac.dblValue() should return the double number 0.5. Use your client program to test this functionality; i.e. provide an output statement to display the double value of a fractionhere are my codes /** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/package lab4; /**** @author engko*/public class Fraction {//Define the class Fraction// declaring instance variablesString res;private int num, denom; // default constructor to initialize instance…arrow_forwardNeed help with following Java method: import java.util.Scanner; import java.lang.Math; public class CosineFromScratch { /* The following code demonstrates how to estimate the cosine of a number. Your assignment is to migrate the calculation of the cosine into a new static method named cosine. The method should take one double input and return one double output. Make sure to call the method from main and set the variable estimate equal to the returned value. */ public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("\nGive me a number: "); double x = input.nextDouble(); //Trying to find cosine of this number double correct_cos = Math.cos(x); //START HERE: The following code goes into //the method. //Source for the following: //https://austinhenley.com/blog/cosine.html double num_terms = 10; int div = (int)(x / Math.PI); x = x - (div * Math.PI); int sign = -1; double estimate = 1.0;…arrow_forwardUse Java program to add a method printReceipt to the CashRegister class. The method should print the prices of all purchased items and the total amount due. Hint: You will need to form a string of all prices. Use the concat method of the String class to add additional items to that string. To turn a price into a string, use the call String.valueOf(price). Also, the payment information will need to be the same as the price information. Here is the CashRegister class: /** A cash register totals up sales and computes change due.*/public class CashRegister{ private double purchase; private double payment; /** Constructs a cash register with no money in it. */ public CashRegister() { purchase = 0; payment = 0; } /** Records the sale of an item. @param amount the price of the item */ public void recordPurchase(double amount) { purchase = purchase + amount; } /** Processes a payment received from the customer. @param…arrow_forward
- I have a Programming Question, The following is a class definition for a simple Ebook. So i need to write a second constructor that takes a String array of pages as input and sets the String array instance variable equal to the input. Continue to default the current page number to zero. Part 2: Write a getter and a setter method for the page number variable. The setter should check to make sure that the input is a valid page number and only update the variable if the new value is valid. Part 3: Write a getCurrentPage method that returns the String of the current page indexed by current_page. Here below are the two instance variables and one parameterless constructor that were provided public class Ebook{ private String[] pages; private int current_page; //constructor public Ebook() { this.pages = {"See Spot.", "See Spot run.", "Run, Spot, run."}; this.current_page = 0; }}arrow_forwardI am trying to add int instance variables for the current hour and minutes of a clock, and I am trying to make them private. I am also trying to write getHour and getMinutes getter methods for these instance variables. I would like to know if I did this correctly and if not, I would like assistance as to what I could change. public class DigitalClock { private int currentHour; private int currentMinutes; public int getHour() { return currentHour; } public void setHour(int currentHour) { this.currentHour = currentHour; } public int getMinutes() { return currentMinutes; } public void setMinutes(int currentMinutes) { this.currentMinutes = currentMinutes;}}arrow_forwardIf the value passed into the parameter x in the following method is 20. What is the value returned by this method? public static int method3(int x) { int sum = 0; for(int i = 1; i <= x; i += 8) sum += i; return sum; }arrow_forward
- Can you do this please? Thank youarrow_forwardCreate an overloaded method to calculate the volume of a box calcVolume(); calcVolume calculates the volume of a rectangle box from a box's width, length and height and then returns the result. calcVolume is overloaded for the special case of a square box, thus only takes in one number that represents width, length and height and then returns the result. Show your method definitions and logic. Call both your methods from the main method and display results.arrow_forwardImage one is my code, I wanted to make some change to the blue part's code. The code I written in red(see image 1) is the method to check that an integer has exactly 5 digits is provided for you (fiveDigits). You just need to call it appropriately in your code(the part in blue square)! Notice that the fiveDigits method returns a boolean - think carefully about how you should use this return type to reprompt the user until they enter a valid zip code. And I want the same output be like (see image 2) for the invalid zip code part: I should only reprompt the user with the message "Invalid zip-code, enter valid zip-code: " until they enter a valid zip code. Similarly, if the user enters an invalid pain level, you should reprompt the user with the message "Invalid pain level, enter valid pain level (1-10): " until they enter a valid pain level. For example(image2)arrow_forward
- For this exercise, we are going to look at how we can create a .equals method. Remember, to compare objects, we cannot just use ==. We need to create a criteria to determine if the objects are equal. In our case, we will say that two people are the same if both the name and birthday match. We are going to write a program that prompts the user for a person’s name and birthday and a student’s name, birthday, and grade, and decide if they are the same person. Start in the Person class creating the .equals method. Remember, this should take the other Person as an input and return a boolean if both the name and birthday are equal. Once completed, create the tester class where you will prompt the user for information. Sample output is provided below. Sample Output Please enter the Person's name: Tanner Please enter the Person's birthday: 5/4/2005 Please enter the Student's name: Tanner Please enter the Student's birthday: 5/4/2005 Please enter the Student's grade: 12 Same: true…arrow_forwardThank you! base on these methods, I want to write one more method Spec for method 5: A method to print a text-based histogram takes one parameter, an array of integers no return value image 2 is the example of expected output. Hint: basically it means base on the file, if number 20 appears once in the file, then I will print one star(*) after the number 20. I think we can get these information from method 4arrow_forwardI'm having trouble understanding how to input the values needed to use the def of getInch and getCm.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY