JAVA!!!! Create a class called Movies C. Create an Array called namesofActress –
ID: 3865540 • Letter: J
Question
JAVA!!!!Create a class called Movies C.
Create an Array called namesofActress – size of 3, which will store actress names.
C. Create a method called actors – method will print the three actress names.
D. Create a method called storeActors – method will store actor name into array, name will be from user.
E. Create a method called salePrice
a. salePrice will calculate ticket price of 8.50 * number of people * TAX(6%)
b. salePrice will print price.
F. Call method called storeActors – with Sarah (HAS A)
G. Call method called storeActors – with Ariel (HAS A)
H. Call method called storeActors – with Mariana (HAS A)
I. Call method called salePrice with an int value of 9
J. Call method called actors.
K. Make a print statement that says “Finished”
Explanation / Answer
Note:
Note : Could you please check the output .If you required any changes Just intimate.I will modify it.Thank You.
______________
Movies.java
public class Movies {
// Declaring String array which holds actress names
String namesofActress[];
static int i = 0;
// Zero argumented constructor
public Movies() {
namesofActress = new String[3];
}
// Method which displays the Actors names
public void actors() {
System.out.println("Displaying the Actors names :");
for (int i = 0; i < namesofActress.length; i++) {
System.out.println(namesofActress[i]);
}
}
// Method which get the name and populate it into an array
public void storeActors(String name) {
namesofActress[i++] = name;
}
// Method which calculate the price of the ticket
public void salePrice(int noOfPeople) {
double price = (8.50 * noOfPeople * 0.06);
System.out.println("The Price is :" + price);
}
}
___________________
Test.java
public class Test {
public static void main(String[] args) {
Movies m = new Movies();
m.storeActors("Sarah");
m.storeActors("Ariel");
m.storeActors("Mariana");
m.salePrice(9);
m.actors();
System.out.println("Finished");
}
}
_________________
Output:
The Price is :4.59
Displaying the Actors names :
Sarah
Ariel
Mariana
Finished
_____________Could you rate me well.Plz .Thank You
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.