4A
Create a class SodaCan that represents a soda can. Provide Javadoc comments for the class, every public method, every parameter, and every return value.
A SodaCan has a radius and height measured in inches. It also has a current contents which is the number of fluid ounces currently in the can.
Provide 2 constructors:
When a SodaCan is created, it is filled to capacity, that is, the contents is the volume of the can expressed in fluid ounces.
In the constructor, in addition to initializing the height and radius, you also need to calculate the capacity and initialize the contents to that value.
To calculate the capacity
Math.PI in the Math class. Provide these accessor methods:
public double getRadius() gets the radius of the SodaCanpublic double getHeight() gets the height of the SodaCanAlso provide these methods (the first is a mutator and the second is an accessor):
public void drink(double fluid_ ounces) simulates drinking from it by subtracting fluid_ounces from the contents.public double getContents() gets the fl. oz. of soda remaining in the SodaCan.Use the constants that are defined for you in the starter class
For the draft , provide the three instance variables, the no-argument constructor, the getHeight(), and getRadius() methods. Remember that instance variables should be private.
4B
Write an application InputApplication. (An application has a main method.)
Create a Scanner object and do the following..
System.out.print("Enter a your favorite dessert: "); (The dessert might be more than one word.)nextLine method to get the wordSystem.out.print("Enter a double: ");Scanner's nextDouble method to get the doubleSystem.out.print("Enter an integer: ");Scanner's nextInt method to get the integerOnly create one Scanner.
For the draft, create the Scanner and do the first three steps.
4C
Write a class StringManipulation to create a Scanner and do the following:
System.out.print("Enter your full name: "); This may be several wordsTo get just the first name, you need to know the index of the first space. You can find the index of the first space with the indexOf method. str.indexOf(" ") will return the index of the first space or -1 if there are no spaces in str. You can assume there is at least one space so you do not need to worry about -1 for this problem.
For the draft, do the first two steps.