Answered step by step
Verified Expert Solution
Question
1 Approved Answer
looking for an expert on Object-oriented Programming, please. It's about Programmer-defined Classes **please separate the questions with the question number** Lab Submissions: Write the appropriate
looking for an expert on Object-oriented Programming, please.
It's about Programmer-defined Classes
**please separate the questions with the question number**
Lab Submissions: Write the appropriate classes for each of the following questions: Question 1 Based on the following class definition, answer the following questions: public class Book { Private String title; Private String author; Private String publisher; Private int copies Sold; } (a) Write a constructor for this class. The constructor should accept an argument for each of the field. (b) Write accessor and mutator methods for each field. Question 2 Write a program, without using objects, that computes the total ticket sales of a concert. There of three types of seatings: A, B, and C. The program accepts the number of tickets sold and the price of a ticket for each of the three types of seats. The total sales are computed as follows: totalSales = numberOfA Seats * pricePer Seat + numberOfB Seats * pricePerB Seat + numberOfC. Seats * pricePerC Seat; Question 3 Redo Exercise 1 by using a Seat class. An instance of the Seat class keeps track of the ticket price for a given type of seat (A, B, or C). Question 4 (a) Define a service class called Rectangle that has two floating-point data members, length and width. The class has a constructor to initialize data members, a method called perimeter( to calculate the perimeter of rectangle, and two methods called setLength() and setWidth( to set the dimensions of the rectangle (length and width) and a member method called describe Program( ) to explain the program to end user. (b) Write a main program to create one object from the above class and test all the method created in the class. Question 5 Write a program that cepts the unit weight of a bag of coffee in kilograms and the number of bags sold and displays the total price of the sale, computed as follows: totalPrice = bagweight * numberOfBags * pricePerkg; totalPriceWithTax = totalPrice + totalPrice * taxRate; Define and use programmer-defined CoffeeBag class. Include class constants for the price per kilogram and tax rate with the values RM5.99 per kilogram and 7.25% respectively. Write a main program to create one object from the above class and test all the method created in the class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started