Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Create a program using classes that does the following in the zyLabs developer below. For this lab, you will be working with two different class files. To switch files, look for where it says "Current File" at the top of the developer window. Click the current file name, then select the file you need.
(1) Create two files to submit:
- ItemToPurchase.java - Class definition
- ShoppingCartPrinter.java - Contains main() method
Build the ItemToPurchase class with the following specifications:
- Private fields
- String itemName - Initialized in default constructor to "none"
- int itemPrice - Initialized in default constructor to 0
- int itemQuantity - Initialized in default constructor to 0
- Default constructor
- Public member methods (mutators & accessors)
- setName() & getName()
- setPrice() & getPrice()
- setQuantity() & getQuantity()
(2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call scnr.nextLine(); to allow the user to input a new string.
(3) Add the costs of the two items together and output the total cost.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please help me with this JAVA exercise. Thank youarrow_forwardWhich of the following is a symptom of Shotgun Surgery bad smell? 1. Whenever make a change, you have to make a lot of little changes to a lot of different classes. 2. When one module changed in different ways for different reasons 3. When a method is making more use of another class than the one it is in 4. When you have sets of variables that are usually passed together in multiple places Pair programming is responsible of introducing bad smells in the code True Falsearrow_forwardDraw Design Layout References Mailings Review View Help Create a Java program and name your file: FIRSTNAME. java (for example, lohn.java). Work on the following: Create three interfaces with the names "InterfaceOne," "IrnterfaceTwo," and "Interfacelhree" In the first interface, declare a method (signature only) with a name "updateGear()." In the second interface, dedare a method (signature only) with a name "accelerate()." In the third interface, dedare a method (signature only) with a name "pusherake()." Create two classes Car and Truck that implement these three interfaces at one time. Define a new method "currentSpeed()" in both the classes to find the current speed after the brake. • Define all the three methods inside each class. The data to these methods will be provided during the object creation. Invoke the two objects with a name c1 of class Car and t1 of class Truck. • After creating the objects, call all the three methods defined above in both the classes. Pass any of the…arrow_forward
- In python, must have docstrings Thank youarrow_forwardImagine we were creating a Textbased Adventure program and our Rooms in the assignment above could hold Items. We are not writing the complete game, but lets write a program that will build the Item.txt file. Create a new project. Add a class called Item that stores information about an item that can be placed in a room. An item has a name, a description and the room number in which the item is initially is stored. LAMP, a brightly shining lamp, 3 is an example of data that an Item might contain. Using the UML model below, create the private data members and methods for constructing an item. Create an ItemFileWriter class with a static method to write the items from the given ArrayList to a text file.. The items text file will hold the item name, item description and the initial room that the item is to be loaded into, on seperate lines followed by a blank line. An example of the file that is to be constructed is attached. Construct a class with main() in it. Create an…arrow_forward● • Compile the Automobile.java class and correct any errors. Create another file named TestAutomobile.java that contains the main method. Create several Automobile objects and test that your constructor and methods work as described. ● Create a UML diagram of the Automobile class. Create the Automobile.java class. It should have the instance variables, constructor(s) and methods located below. Automobile Instance variables Reminder: + indicates public, - indicates private - make (String): The automobile make (Ford, Acura, etc). - model (String): The automobile model (Escapade, ZDX, etc). - power (boolean): Holds the value true if the power is on and false if the power is off. The default value is false. . - gear (char): Holds the value of the gear that the automobile is in. The default value is P (Park). Other values include D (Drive), and R (Reverse). Automobile constructors • One constructor that takes two parameters and sets the make and model instance variables. . - volume (int):…arrow_forward
- Implement a graphical application that displays a list of courses. Briefly, this GUI will take the inputs (i.e., course information), store them in an array list, and display course information in the output area. Figure 1 shows the layout ofthe CourseDisplay GUI. You should have three Java files: 1. CourseDisplayFrame class that extendsJFrame class (The main part of your program). 2.CourseDisplayViewer class, which contains the main method where a CourseDisplay object will be created, and the GUI will pop up (Suggested frame width of 450, and frame height of 400). 3.Course class, which is the class that models the Course objects (This file will be given to you). In your CourseDisplayFrame class file, you should have the followings: •Input area: –A text label and a text field (suggested width of 30) for course code; –A text label and a text field (suggested width of 30) for course name; –A text label and a text field (suggested width of 30) for course credit; –A text label and a text…arrow_forwardCan someone please help with this program in Java? Create a Question.Java class Only and create a methods within the class. Please do not paste the existing answer with three classes (Question.Java, Player.Java, and Trivia.Java). Thank you!!arrow_forwardFor this lab task, you will work with classes and objects. Create a class named text that works similar to the built-in string class. You will need to define a constructor that can be used to initialize objects of this new class with some literal text. Next, define three methods: to_upper() that will convert all characters to uppercase, reverse() that will reverse the text and length() that will return the length of the text. After you have completed this part, copy the following mainfunction to your code and check if the implementation is correct. int main() { text sample = "This is a sample text"; cout << sample.to_upper(); // This should display "THIS IS A SAMPLE TEXT" cout << endl;cout << sample.reverse(); // This should display "txet elpmas a si sihT"cout << endl; cout << sample.length(); // This should display 21 }arrow_forward
- To use any of the prewritten classes besides those in the java.lang package, you must___ a. use the entire path with the class name b. import the class c. import the package of which the class you are using is a part d. use any of these methodsarrow_forwardCreate a program using classes that does the following in the zyLabs developer below. For this lab, you will be working with two different class files. To switch files, look for where it says "Current File" at the top of the developer window. Click the current file name, then select the file you need.(1) Create two files to submit: ItemToPurchase.java - Class definition ShoppingCartPrinter.java - Contains main() method Build the ItemToPurchase class with the following specifications: Private fields String itemName - Initialized in default constructor to "none" int itemPrice - Initialized in default constructor to 0 int itemQuantity - Initialized in default constructor to 0 Default constructor Public member methods (mutators & accessors) setName() & getName() setPrice() & getPrice() setQuantity() & getQuantity() (2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call…arrow_forwardJAVA PROGRAMMING Create a class named "Circle" that has attributes radius, area and circumference and make the attributes private. Make a public method that sets the radius and method that prints all attributes. Ask the user input for radius. Note: Use the PI from the math functions. Inputs: 1. A line containing an integer. 10 Output: Radius: 20 Area: 1256.64 Circumference: 125.66arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education