A public static method named compute sum()

public static boolean endOther(String a, String b)

Define it as follows:

Given two strings, return true if either of the strings appears at the very end of the other string, ignoring upper/lower case differences

endOther("Hiabc", "abc") →true

endOther("AbC", "HiaBc") →true

endOther("abc", "abXabc") →true

method with the following header:

public static int sum13(int[] nums)

Define it as follows:

Return the sum of

the numbers in the array, returning 0 for an empty array. Except the number 13

is very unlucky, so it does not count and numbers that come immediately after a 13 also do not

count.

sum13([1, 2, 2, 1]) →6

sum13([1, 1]) →2

sum13([1, 2, 2, 1, 13]) →6

sum13([13, 1, 2, 13, 3, 3]) →5

  • Create a class called FinalGrade that is used to represent the points obtained in the letter grade of CSC 110 by different students. The FinalGrade class should include three pieces of information as instance variables—studentName (type String), studentID (type String), and pointsObtained (type int). Your class should have a constructor that initializes the three instance variables. Provide a set and a get method for each and every instance variable. In addition, provide a method named computeLetterGrade that returns the letter grade obtained by the student taking the pointsObtained as an argument. For the grading policy refer to CSC 110 grading scheme specified in syllabus. Write a test application named FinalGradeDriver that creates at least 3 different objects of class FinalGrade and test all the methods of class FinalGrade.   Sample Output Student Name : Homer SimpsonStudent ID : S123456Points Obtained : 99Letter Grade : A Student Name : Marge SimpsonStudent ID : S234567Points…

    (The Rectangle class) Following the example of the Circle class in Section 8.2,design a class named Rectangle to represent a rectangle. The class contains:■ Two double data fields named width and height that specify the width andheight of the rectangle. The default values are 1 for both width and height.■ A no-arg constructor that creates a default rectangle.■ A constructor that creates a rectangle with the specified width and height.■ A method named getArea() that returns the area of this rectangle.■ A method named getPerimeter() that returns the perimeter.Draw the UML diagram for the class and then implement the class. Write a testprogram that creates two Rectangle objects—one with width 4 and height 40and the other with width 3.5 and height 35.9. Display the width, height, area,and perimeter of each rectangle in this order.

    a. Carly's Catering provides meals for parties and special events. In Chapters 3 and 4, you created an Event class for the company. Now, make the following changes to the class: Currently, the class contains a field that holds the price for an Event. Now add another field that holds the price per guest, and add a public method to return its value. Currently, the class contains a constant for the price per guest. Replace that field with two fields—a lower price per guest that is $32, and a higher price per guest that is $35. Add a new method named isLargeEvent() that returns true if the number of guests is 50 or greater and otherwise returns false. Modify the method that sets the number of guests so that a large Event (more than 50 guests) uses the lower price per guest to set the new pricePerGuest field and calculate the total Event price. A small Event uses the higher price.   Save the file as Event.java. b. In Chapter 4, you modified the EventDemo class to demonstrate two Event…

  • Modify the program below and add a public method called isZero() to the Fraction class. This method will determine if a Fraction represents a zero fraction. A zero fraction has a numerator == 0, no matter what the denominator is. Your isZero() method should return a Boolean resultindicating a zero fraction or otherwise. The method will be used by the client class to test whether the ‘calling fraction’ is equal to the number zero. Modify the program so that it now loops until a fraction representing zero is entered. //Import the essential package import java.util.ArrayList; import java.util.Scanner; //Define the class Fraction class Fraction {     private int n, d;       public Fraction()     {         //Initialize the values         this.n = this.d = 0;     }     public Fraction(int n, int d)     {         //Initialize the variables         this.n = n;         this.d = d;     }     //Define the getter function getNum() that returns the numerator     public int getNum()     {…

    Create an application via NetBeans with named Pizza that storesinformation about a single pizza. It should contain the following:• Private instance variables to store the size of the pizza (eithersmall, medium, or large), the number of cheese toppings, the number ofbeef toppings, and the number of chicken toppings.• Constructor(s) that set all of the instance variables.• Public methods to get and set the instance variables.• A public method named calcCost( ) that returns a double that is thecost of the pizza.Pizza cost is determined by: Small: OR10 + OR 2 per topping Medium: OR 12 + OR 2 per topping Large: OR 14 + OR 2 per topping• A public method named getDescription( ) that returns a Stringcontaining the pizza size, quantity of each topping, and the pizzacost as calculated by calcCost( ).

    Implement a class named Rectangle to represent a rectangle using Java 1) Class name: Rectangle; accessibility: public 2) The class contains: Two private double data fields named width and height that specify the width and height of the rectangle. 3) A no-arg constructor that creates a default rectangle: data fields are 1 for both width and height. 4) A constructor that creates a rectangle with the specified width and height. 5) A public method named setWidth that sets the value of width 6) A public method named getWidth that returns the value of width 7) A public method named setHeight that sets the value of height 8) A public method named getHeight that returns the value of height 9) A public method named getPerimeter() that returns the perimeter. 10) A public method named getArea() that returns the area of this rectangle. 11) Draw the UML class diagram 12) Write a test file that creates two Rectangle objects: one with width 4 and height 40 and the other with width 3.5 and…

  • Following the example of the Rectangle class of Chapter 9 Exercise 1, design a class named Cuboid to represent a cuboid. The class contains: Three data fields named length, width, and height. A constructor that creates a cuboid with the specified length, width, and height. A method named getVolume() that returns the volume of this cuboid. Then, please create an object mycuboid = Cuboid (2, 3, 4), and invoke getVolume to print the volume of mycuboid.

    Following the example of the Circle class in Section 9.2 , design a class named Stock that contains: A string data field named symbol for the stock’s symbol. A string data field named name for the stock’s name. A double data field named previousClosingPrice that stores the stock price for the previous day. A double data field named currentPrice that stores the stock price for the current time.   A constructor that creates a stock with the specified symbol and name.   A method named getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice.   Write a test program that creates a Stock object with the stock symbol ORCL, the name ­Oracle Corporation, and the previous closing price of 34.5. Set a new current price to 34.35. Select 9 more stocks with the current prices and create objects with the current prices as previous Closing prices. After 2 or more days get the price for each stock in your list and use the currentPrice method to store the current…

    This is the question - The developers of a free online game named Sugar Smash have asked you to develop a class named SugarSmashPlayer that holds data about a single player. The class contains the following fields: idNumber - the player’s ID number (of type int) name - the player's screen name (of type String) scores - an array of integers that stores the highest score achieved in each of 10 game levels Include get and set methods for each field. The get method for scores should require the game level to retrieve the score for. The set method for scores should require two parameters—one that represents the score achieved and one that represents the game level to be retrieved or assigned. Display an error message if the user attempts to assign or retrieve a score from a level that is out of range for the array of scores. Additionally, no level except the first one should be set unless the user has earned at least 100 points at each previous level. If a user tries to set a score for a…

  • arrow_back_ios

    arrow_forward_ios