Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Java: Intro. to Prob. Solv... (Looseleaf)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Computer Science: An Overview (12th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- Write a JAVA program to model the kinds of people one finds in a university. The categories are students, teachers and teaching assistant (TAs). All these categories are kinds of Person (Person is abstract class. A teaching assistant (TA) is a student and a teacher as well. A person has a name (string). A student has grade point average GPA (between 0 to 4), the teacher has the number of scholarly papers he/she has published and the teacher assistant has the number of courses he/she assists. All the classes contain constructors with default arguments to fill all data spaces. Provide display method to print all data members of an object on the screen. Classes also contain a function called isSuccessful(). Students with a GPA over 3.5 are considered successful. This function returns true if someone is successful or false if not. In main(), define an array of Person class, which can point to students, teachers and teacher assistants. The program first asks the kind of person and then lets…arrow_forwardWrite a java program in a class CountPoor that counts the number of families that are considered poor. Write and use a class Family that has the attributes. income—a double value that is the income for the family size—the number of people in the family and the following methods: Family(income, size)—a constructor that sets the attributes isPoor(housingCost, foodCost)—a method that returns true if housingCost + foodCost * size is greater than half the family income (foodCost is the average food cost for an individual, while housingCost is for the family) toString—a method that returns a string containing the information about the family The program should read an integer k from the keyboard and then create an array of size k whose base type is Family. It should then create k objects of type Family and put them in the array, reading the income…arrow_forwardWrite a Java program for a class named Baby. A Baby has a name of type String and an ageof type integer.Supply two constructors: one will be the default constructor, that just setsdefault values for the name and age; the second constructor will take twoparameters, a string to set the name and an integer to set the age. Also, supplymethods for setting the name, setting the age, getting the name and getting theage.The class should not contain I/O methods; input of values to the instancevariables must be done with a set method or constructor, output of values fromthe instance variables must be done with get methods. The set method for thename instance variable should ensure that the input is not empty or containwhitespaces (otherwise set a default value). The set method for the ageinstance variable should validate the input to be between 1 and 4 inclusive(otherwise set a default value).Give Java code for an equals method for the Baby class. Babies count asbeing the same (i.e. equal) if…arrow_forward
- Implement the design of the Passenger class so that the following output is produced: The assumption is Bus base-fare is 450 taka. A passenger can carry upto 20 kg for free. 50 taka will be added if bag weight is between 21 and 50 kg. 100 taka will be added if bag weight is greater than 50 kg. [You are not allowed to change the code below] # Write your code here print(“Total Passenger:”, Passenger.count) p1 = Passenger(“Jack”) p1.set_bag_weight(90) p2 = Passenger(“Carol”) p2.set_bag_weight(10) p3 = Passenger(“Mike”) p3.set_bag_weight(25) print("=========================") p1.printDetail() print("=========================") p2.printDetail() print("=========================") p3.printDetail() print("=========================") print(“Total Passenger:”, Passenger.count) Output: Total Passenger: 0 ========================= Name: Jack Bus Fare: 550 taka ========================= Name: Carol Bus Fare: 450 taka ========================= Name: Mike Bus Fare: 500 taka =========================…arrow_forwardwrite a discount system for a beauty saloon using java program, which provides services and sells beauty products. It offers 3 types of memberships: Premium, Gold and Silver. Premium, gold and silver members receive a discount of 20%, 15%, and 10%, respectively, for all services provided. Customers without membership receive no discount. All members receives a flat 10% discount on products purchased (this might change in future). Your system shall consist of three classes: Customer, Discount and Visit, as shown in the class diagram. It shall compute the total bill if a customer purchases $x of products and $y of services, for a visit. Also write a test program to exercise all the classes. Don’t forget to use array customer name and member type.arrow_forwardIN C++ Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km—pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Provide another parameterized constructor which takes both efficiency and fuel as parameters. Also supply methods getGasInTank, returning the current amount of gasoline in the fuel tank. getEfficiency() return the efficiency of car. setGasInTank(double fuel), to add gasoline to the fuel tank. setEfficiency(double efficiency) Supply a method Drive () that simulates driving the car for a certain distance, reducing the amount of gasoline in the fuel tank according to its efficiency. Sample usage: Car myHybrid (50); // 50 miles per gallon myHybrid.addGas(20); // Tank 20 gallons myHybrid.Drive(100); // Drive 100 miles double gasLeft = myHybrid.getGasInTank(); // Get gas remaining in tank Supply a main method that tests…arrow_forward
- Write a program that would print the information (name, year of joining, salary, address) of three employees by creating a class named 'Employee'. The output should be as follows:Name Year of joining AddressRobert 1994 64C- WallsStreatSam 2000 68D- WallsStreatJohn 1999 26B- WallsStreatarrow_forwardWrite a Java program: In the board game Scrabble, each tile contains a letter, which is used to spell words in rows and columns, and a score, which is used to determine the value of words. The point of this exercise is to practice the mechanical part of creating a new class definition: Write a definition for a class named Tile that represents Scrabble tiles. The instance variables should be a character named "letter" and an integer named "value". Write a constructor that takes parameters named letter and value, and initializes the instance variables. Create getters for both of the attributes. (No setters, so that a Tile is immutable.) Implement the .toString() and .equals methods for a Tile.arrow_forwardWrite a program that uses a bar chart to display the percentagesof the overall market share represented by Apple, HTC, Samsung, andOthers, as shown in Figure . Suppose that Apple takes 20 percent and isdisplayed in red, HTC takes 26 percent and is displayed in blue, Samsung takes28 percent and is displayed in green, and the Others take 26 and are displayedin orange. Use the Rectangle class to display the bars. Interested readers mayexplore the JavaFX BarChart class for further study.arrow_forward
- Write a simple cash register class. (Use Java) Each cash register should keep track of the number of items checked out and the total cash in the register. We are only concerned with the number of items to check out and their prices. No need to handle item names, SKUs, taxes, etc... It should have the following methods (use static when appropriate): checkout( ) Takes two forms. If there is only one parameter that is the cash received and there is only one item checked out. If it has two parameters, the first parameter should have the number of items checked out and the second parameter is the price per item. cashout( ) Reset the number of items and total cash to zero for a cash register getItems( ) Returns the number of items in the cash register getTotalCash( ) Returns the total cash in the cash register getAveragePricePerItem( ) Returns the average price per item checked out by the cash register getRegisterCount( ) Returns the number of cash registers created getAllItems(…arrow_forwardConsider a class Movie that contains the following information about a movie. The class has the following attributes: Title MPAA Rating (e.g. G, PG, PG-13, R) Number of people who rated this movie as a 1 (Terrible) Number of people who rated this movie as a 2 (Bad) Number of people who rated this movie as a 3 (OK) Number of people who rated this movie as a 4 (Good) Number of people who rated this movie as a 5 (Great) Implement the Movie class such that it is able to contain the above information. Include constructor that would accept two parameters and initialize the movie's title to the value of its first parameter and the movie's MPAA rating to the value of its second parameter, and public rating to 0. Also include access member functions for title and MPAA rating. Include a member function to increment the public rating that will only accept integer values between 1 and 5. Finally, write a member function that would return the average public rating of a movie. Write a…arrow_forwardWrite a program in the Java language requires the management of university students, where student data (name, student number, and specialization) are saved, and then he can add and delete study materials for the current semester, and you can also add the grade for each subject (with the addition of the final code for the degree automatically).Note: The class principle is used to solve this assignment.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education