1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erma4kov [3.2K]
3 years ago
12

g You have a class called Product (with both an empty constructor and a second constructor that takes a quantity and a price as

parameters.) It has a quantity and price as internal data and has get() and set() methods for them. Write the code to create two objects of type Product, and set their two data values to some test data of your choosing. (4 pojnts) --below that also do this-- Later on in the program you created with the code from the question above, you need to display the items for the user. Write the lines of code to display the two Product objects data (that you created above) to the user. (4 points)
Computers and Technology
1 answer:
Naya [18.7K]3 years ago
8 0

Answer:

The answer using java programming language is in the explanation section

See detailed explanations in the comments within the code

Explanation:

//The class Product begins here

public class Product {

   private int quantity;

   private double price;

   //First Constructor No argument

   public Product() {

   }

   //Second Constructor Two argument

   public Product(int quantity, double price) {

       this.quantity = quantity;

       this.price = price;

   }

   //Get Methods

   public int getQuantity() {

       return quantity;

   }

   public double getPrice() {

       return price;

   }

   //Set Methods

   public void setQuantity(int quantity) {

       this.quantity = quantity;

   }

   public void setPrice(double price) {

       this.price = price;

   }

}

//End of Product Class

//Test class containing the main method begins here

class ProductTest{

   public static void main(String[] args) {

       //Creating two objects of Product

       Product productOne = new Product(1000, 50.5);

       Product productTwo = new Product (5000, 60);

       //Displaying the product object's data

       System.out.println("Product one quantity is "+productOne.getQuantity()+" and the unit price is" +

               "is "+productOne.getPrice());

       System.out.println("Product Two quantity is "+productTwo.getQuantity()+" and the unit price is" +

               "is "+productTwo.getPrice());

   }

}

You might be interested in
For this assignment, you will write a program that calculates gross and net revenue for a movie theater. Consider the following
Marrrta [24]

Answer:

// This program is written in C++

// Comments are used for explanatory purpose

#include<iostream>

using namespace std;

int main()

{

// Declare variables

int childticket, adultticket, childprice, adultprice;

double total, net, distributor;

string movie;

// Prompt user for name of movie

cout<<"Movie Name; ";

// Accept input for movie name

cin>>movie;

// Prompt user and accept input for price of adult tickets

cout<<"Adult Ticket Price: $";

cin>>adultprice;

// Prompt user and accept input for price of child tickets

cout<<"Child Ticket Price: $";

cin>>childprice;

// Prompt user and accept input for number of sold adult tickets

cout<<"Adult Ticket Sold: ";

cin>>adultticket;

// Prompt user and accept input for number of child tickets sold

cout<<"Child Ticket Sold: ";

cin>>childticket;

// Calculate total

total = childticket * childprice + adultticket * adultprice;

// Calculate distributor's payment

distributor = 0.25 * total;

// Calculate net box pay

net = 0.75 * total;

// Display and format results

cout<<"Gross Box Office Revenue: $";

printf("%.2f",total);

cout<<"\n Amount Paid to Distributor: -$";

printf("%.2f", distributor);

cout<<"\nNet Box Office Revenue: $";

printf("%.2f",net);

return 0;

}

6 0
3 years ago
How to disappear completely from the internet pc magazine
GREYUIT [131]

In order to disappear completely from the internet, one needs to delete their social media accounts, delete their emails, etc.

The internet is a network of interconnected computer systems. Despite its numerous advantages, it also has several disadvantages and there are some moments when we want to disappear from the internet.

The steps that are needed to disappear from the internet include:

  • Delete your social network accounts.
  • Delete your email accounts.
  • Use search engines to track your old activities online and delete them.
  • Falsify the accounts that can't be deleted.
  • Unsubscribe from mailing lists.

Read related link on:

brainly.com/question/24902823

4 0
3 years ago
Help...! Why might you trace an image<br> A. To edit an image<br> B. To make drawing easier
pav-90 [236]

Answer:

the answer is b

5 0
4 years ago
A plan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedul
vesna_86 [32]

Answer:

A study routine

Explanation:

6 0
3 years ago
Read 2 more answers
In every programming language, when you access data stored in an array, you must use a ____ containing a value that accesses mem
Mariulka [41]
An array is an indexed collection of data elements. First you must declare an array, give its name and data. <span>Once your arrays are declared, you access the elements in an array with the array name, and the index number inside brackets [ ].
So, in every </span><span>programming language, when you access data stored in an array, you must use a command [] (brackets) containing a value that accesses memory occupied by the array.</span>
4 0
3 years ago
Other questions:
  • You have just deployed SNMPv3 in your environment. Your manager asks you to make sure that your SNMP agents can only talk to the
    13·2 answers
  • This formatting option functions like a space bar. However, instead of moving one space at a time, it allows you to move your te
    6·1 answer
  • OSHA has authority over the employers of
    5·2 answers
  • Riley is using access to collect data for a science project. he is creating a report and wants to apply predefined color and fon
    6·1 answer
  • The American Footwear and Apparel Group exerts pressure
    12·1 answer
  • My programming lab 9.2 C++ Write a full class definition for a class named Counter, and containing the following members:_______
    6·1 answer
  • 1. If your motherboard supports DIMM memory, will RIMM memory still work<br>on the board?​
    13·1 answer
  • _____emphasizes on proper breathing and the mind-body-spirit connections.​
    6·2 answers
  • Related to Image Classification
    13·1 answer
  • Which of the following is NOT a reason why supply chain infections areconsidered especially dangerous?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!