/* I used Item as class name also see screenshot for indentation*/
/* Item.java */
public class Item {
// Instance variable
private String name;
private double price;
// default constructor
public Item(){
name = "Unknown";
price = 1;
}
// overload constructor
public Item(String name, double price) {
this.name = name;
this.price = price;
}
// Getter and setters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}

/* ItemDriver.java */ // Main function class
import java.util.Scanner;
import javax.swing.JOptionPane;
public class ItemDriver {
public static void main(String[] args) {
Item item1 = new Item(); // using default object
Item item2 = new Item("Ab12",250); // using given name and
price
Scanner sc = new Scanner(System.in); // for user input
System.out.print("Enter name of item: ");
String item = sc.nextLine(); // take item name input
System.out.print("Enter Price of item: ");
double price = sc.nextDouble(); // take price input
Item item3 = new Item(item,price); // using scanner
item = JOptionPane.showInputDialog("Enter name of item: "); // take
item name input
price = Double.parseDouble(JOptionPane.showInputDialog("Enter name
of price: "));
Item item4 = new Item(item,price);// using JOption pane
Item item5 = new Item("BC456",2*item3.getPrice()); // SET double
price of item3 in item5
item1.setPrice((item1.getPrice()+item1.getPrice()*0.1)); //
INCREASE PRICE BY 10%
double totalprice = item1.getPrice() + item2.getPrice() +
item3.getPrice()
+ item4.getPrice() + item5.getPrice(); // find total price
String info = "Item1 Name: "+item1.getName() +" Price:
"+item1.getPrice()+"\n"
+ "Item2 Name: "+item2.getName() +" Price:
"+item2.getPrice()+"\n"
+ "Item3 Name: "+item3.getName() +" Price:
"+item3.getPrice()+"\n"
+ "Item4 Name: "+item4.getName() +" Price:
"+item4.getPrice()+"\n"
+ "Item5 Name: "+item4.getName() +" Price:
"+item5.getPrice()+"\n"
+ "Total Price: "+ totalprice;
JOptionPane.showMessageDialog(null,info);
}
}
![import java.util.Scanner; import javax.swing.JOptionPane; public class ItemDriver { public static void main(String[] args) {](http://img.homeworklib.com/questions/c9b3aca0-5522-11eb-9a69-a357f74dac2c.png?x-oss-process=image/resize,w_560)
/* OUTPUT */



Hi , i have facing problems in both 5 error while i am soloving it can...
Need help solving this qestion related to object and item classes involving arrays in PYTHON. Classes and Object - Inventory Item as Object In this assignment the idea is to use an Item class to capture what you need for recording and displaying the details of an order from an online store like Amazon. This is a Class and Object assignment. For the assignment you must define and implement the Item class so that the code shown immediately below can...
In Python a class can inherit from more than one class (Java does not allow this). The resulting class will have all the methods and attributes from the parent classes. Do the following: • Create a class called Person. In the class, define variables for storing date of birth, place of birth, and male/female attributes. In the class, define the constructor method, as well as methods for returning current values of the class attributes. • Create a class called Employee....
QUESTION 1 The following tables form part of a database held in a relational DBMS for storing the information of Customer, Item, Transaction, and temSale A transaction can contain multiple items and an item can be in multiple transactions as depicted in the following sample data Item(itemid, name, category, price Itemid pk) name category price Iteml Pencil Stationery $30 paperStationery Item2 $25 $15 Item3 Cards Stationery S40 Item4 Ink Stationery S13 Item5 Sprite Itemo Food S4 Milk Food Transaction ctransid,...
Problem Description to implement a Java application, called ShoppingApplication, that can be used in a retail store. You are asked to implement three classes: Item, Invoice, and InvoiceDriver. Each of these classes is described below. Item class The Item class represents of an item that is being sold in the retail store (e.g., book or pencil) where an item is identified by three instance variables: name (of type Sring), weight (of type double), price (of type double), and currentDiscount (of...
The Secondhand Rose Resale Shop is having a seven-day sale during which the price of any unsold item drops 10 percent each day. Design an Inventory class that contains an item number and the original price of the item. A default constructor that initializes each attribute to some reasonable default value for a non-existent inventory item. Another constructor that has a parameter for each data member. This constructor initializes each attribute to the value provided when an object of this...
In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...
Deliverable
A zipped NetBeans project with 2 classes
app
ZipCode
Address
Classes
Suggestion:
Use Netbeans to copy your last lab (Lab 03) to a new
project called Lab04.
Close Lab03.
Work on the new Lab04 project then.
The Address Class
Attributes
int number
String name
String type
ZipCode zip
String state
Constructors
one constructor with no input parameters
since it doesn't receive any input values, you need to use the
default values below:
number - 0
name - "N/A"
type...
Java Eclipse Coding question: Use data abstraction (real-world modeling) to come up with 3 instance variables and 2 effectors for a new data type – the class HospitalPatient. You have the freedom to design the instance variables and effectors. instance variables effectors 1. 1. 2. 2. 3. Write the code for class HospitalPatient, according to the requirement above. Include the default constructors with no argument, and the constructor with all arguments. Provide a getter and setter for each individual instance...
Create an Item class, which is the abstract super class of all Items. Item class includes an attribute, description of type String for every item. [for eg. Book] A constructor to initialize its data member of Item class. Override toString() method to return details about the Item class. Create the ExtraCharge interface with the following details. Declare a constant RATE with value 0.25 Declare a method called calculateExtraCharge(), which returns a double value. Create the...
Assignment Requirements
I have also attached a Class Diagram that describes the
hierarchy of the inheritance and interface behaviors . The link to
the PDF of the diagram is below
MotorVehical.pdf
Minimize File Preview
User Define Object Assignment:
Create a Intellij Project. The
Intellij project will contain three user defined
classes. The project will test two of the User Define Classes by
using the invoking each of their methods and printing the
results.
You are required to create three UML...