Question & Answer: Please help me answer this java coding question. In java format. I have 45 minutes to anawer…..

Please help me answer this java coding question. In java format. I have 45 minutes to anawer

Page 4 Code a simple class program called OnceUponATime. This program is in a package called fairyTales. In the OnceUponATime proaram code a no-args/empty constructor, then, code an 34. of the main character. The overloaded constructor will print the name for the story along with the main character s name as part of the message below. In the main) of an application program calle TestOnceUponATime, Sleeping Beauty and Princess Aurora. (10 points) instantiate an object of the OnceUponATime class and send to it Message to be printed in the overloaded constructor: The fairy tale is Xxxxxxxxxxx and its leading character is Xxxxxxxxxx.

Page 4 Code a simple class program called OnceUponATime. This program is in a package called fairyTales. In the OnceUponATime proaram code a no-args/empty constructor, then, code an 34. of the main character. The overloaded constructor will print the name for the story along with the main character s name as part of the message below. In the main) of an application program calle TestOnceUponATime, “Sleeping Beauty” and “Princess Aurora”. (10 points) instantiate an object of the OnceUponATime class and send to it Message to be printed in the overloaded constructor: The fairy tale is Xxxxxxxxxxx and its leading character is Xxxxxxxxxx.

Expert Answer

 

Java Code:

package fairytales;

//Class definition
class OnceUponATime
{
//Default / No-arg Constructor
public OnceUponATime() {
//Printing message
System.out.println(“n Fairy Tale…. n”);
}

//Arg Constructor
public OnceUponATime(String story, String mainCharacter) {
//Printing message (Starting character in Upper case)
System.out.printf(“n The fairy tale is %s and its leading character is %s n”, (story.substring(0, 1).toUpperCase()+story.substring(1)), (mainCharacter.substring(0, 1).toUpperCase()+mainCharacter.substring(1)));
}
}

//Driver class
public class TestOnceUponATime {
//Main method
public static void main(String[] args) {

//Creating an object
OnceUponATime tale = new OnceUponATime(“Sleeping Beauty”, “Princess Aurora”);
}
}

_____________________________________________________________________________________________

Sample Run:

Question & Answer: Please help me answer this java coding question. In java format. I have 45 minutes to anawer..... 1

Still stressed from student homework?
Get quality assistance from academic writers!