Question: (JAVA) Please only give one answer to each question! 1) Write a program that calls the digitName() method that you defined in the previous question.

(JAVA)

Please only give one answer to each question!

1)

Write a program that calls the digitName() method that you defined in the previous question. Your program will ask the user to type a single digit, read the user's response into an int variable, and then print the name of the user's digit. You can assume that the user will follow instructions.

2)

Read the documentation for the predefined class Point, in the java.awt:

https://docs.oracle.com/javase/7/docs/api/index.html (Links to an external site.)Links to an external site.

Define an ArrayList of Point objects. Create three new Point objects with the following (x, y) values: (0,6), (4,10), (7,1). Add these three new Point objects to the ArrayList. After all three Point objects are in the ArrayList, print the ArrayList to show that the Points are in the list.

3)

Write the definition of a new class Date. One object of class Date represent the month, day and year for one date on the calendar. I have given you the main( ), and you must provide the class definition that will run the given main( ) and print the given output. You only need to define the methods required by this main( ) :

public static void main(String[] args) { Date today; today = new Date( ); today.setMonth(6); today.setDay (25); today.setYear(2018); System.out.println(today); }

4)

Assume that you are given a price in a String variable, and you need to take a discount off of that price in order to calculate the total. Recall that you cannot perform numeric calculations on String values. You will need to convert the String value into a double value in order to perform arithmetic on it. Luckily, there is a method in the Java API that converts a String value into a double value. This method is called Double.parseDouble(), and it is defined inside class Double. You do not have to import anything to call this method since class Double is inside the java.lang package.

In the following program, add the code that calls the method Double.parseDouble() to convert the String priceInString into the double priceInDouble.

final double DISCOUNT = .15; String priceInString; priceInString = "9.99"; double priceInDouble; priceInDouble = // this is where your code will go double total; total = priceInDouble - (priceInDouble * DISCOUNT); System.out.println("The total including discount is: " + total);

Please type just the code that will go on the right hand side of the assignment operator, where you see the comment "// this is where your code will go"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!