Question

COSC 1047-Final Exam- Winter 2019 games and action figures. public interface Inventoryitem I Return the value of an item (qua


COSC 1047-Flhal Exdill fou work for a store that sells comics, board games and action figures. public interface Inventoryitem
COSC 1047-Final Exam- Winter 2019 games and action figures. public interface Inventoryitem I Return the value of an item (quantity on public double getItemValue () 3 hand setall price)- Set the quantity of that iten in the stoce public void setQuantitylint qty) 7Return the inventory part number. public int getFartNumber o (6 marks) Assume that there are Comic, BoardGame and ActionFigure classes already written and that all thre implement Inventoryltem. Write statements to accomplish the following a. . Create an array that stores a comic book item, a board game item and an action figure item . Assume that the constructor for each takes in a String (short description), an int (part a double (retail price). . Set the quantity of each item on hand to be something O. Using a for loop, compute (and eventually print) the total value of all items in the store. Determine which item has the lowest part number. .
COSC 1047-Flhal Exdill fou work for a store that sells comics, board games and action figures. public interface Inventoryitem 77 Return the value of an item (quantity on hand retail price) public double getItemValue O) : // Set the quantity of that item in the store public void setQuantity(int qty) // Return the inventory part number public int getPartNumber O 6 marks) Assume that there are Comic, BoardGame and ActionFigure classes already written and that all three implement Inventoryltem. Write statements to accomplish the following: Create an array that stores a comic book item, a board game item and an action figure item. Assume that the constructor for each takes in a String (short description), an int (part number), a double (retail price). Set the quantity of each item on hand to be something>O Using a for loop, compute (and eventually print) the total value of all items in the store. Determine which item has the lowest part number. . .
0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Main
{
double total=0; int lowest;
Comic c[] = new Comic[2]; //array for comics
BoardGame b[] = new BoardGame[2]; //array for BoardGame
ActionFigure a[] = new ActionFigure[2]; //array for ActionFigure
  
c[0] = new Comic("Marvel",5,29.3); //initialize
c[1] = new Comic("DC",3,19.3);
  
b[0] = new BoardGame("Monopoly",25,629.3);
b[1] = new BoardGame("Business",15,529.3);
  
a[0] = new ActionFigure("Batman",6,829.3);
a[1] = new ActionFigure("Superman",12,1029.3);
  
a[0].setQuantity(12);
a[1].setQuantity(23);
b[0].setQuantity(3);
b[1].setQuantity(2);
c[0].setQuantity(123);
c[1].setQuantity(203); //initialization over
  
lowest = a[0].getPartNumber(); //initializing lowest
  
for (int i=0; i<a.size(); i++) //calculating total
total = total + a[i].getItemValue();
for (int i=0; i<b.size(); i++)
total = total + b[i].getItemValue();
for (int i=0; i<c.size(); i++)
total = total + c[i].getItemValue();
  
System.out.println("Total:\t"+total);
  
for (int i=0; i<a.size(); i++) //calculating lowest value
if(a[i].getItemValue()<lowest)
lowest = a[i].getItemValue();
for (int i=0; i<b.size(); i++)
if(b[i].getItemValue()<lowest)
lowest = b[i].getItemValue();
for (int i=0; i<c.size(); i++)
if(c[i].getItemValue()<lowest)
lowest = c[i].getItemValue();
  
}

COMMENT DOWN FOR ANY QUERIES AND,

LEAVE A THUMBS UP IF THIS ANSWER HELPS YOU.

Add a comment
Know the answer?
Add Answer to:
COSC 1047-Final Exam- Winter 2019 games and action figures. public interface Inventoryitem I Retu...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "Ret...

    in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "RetailItem" class which simulates the sale of a retail item. It should have a constructor that accepts a "RetailItem" object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. Your class should have these methods: getSubtotal: returns the subtotal of the sale, which is quantity times price....

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • Java 1. Develop a program to emulate a purchase transaction at a retail store. This program...

    Java 1. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual line item of merchandise that a customer is purchasing. The Transaction class will combine several LineItem objects and calculate an overall total price for the line item within the transaction. There will also be two test classes, one for the LineItem class and one for the...

  • C++ Retailltem.h, Retailltem.cpp, Store.h, Store.cpp, and Driver.cpp. Description: Write a set of programs that holds data...

    C++ Retailltem.h, Retailltem.cpp, Store.h, Store.cpp, and Driver.cpp. Description: Write a set of programs that holds data about items in a retail store. Your submission should include 5 files, Retailltem.b, Retailltem.cpp, Store, Store.cpp, and Driver.cpp 1. Retailltem class: The class should have three member variables • description (a string, represent the item's name. A name contains space) quantity (an int, represent how many current available) price (a double, item's price) Member Functions Constructor with default argument get Description getQuantity getPrice setDescription...

  • Write a program in C++ that simulates a soft drink machine. The program will need several...

    Write a program in C++ that simulates a soft drink machine. The program will need several classes: DrinkItem, DrinkMachine and Receipt. For each of the classes you must create the constructors and member functions required below. You can, optionally, add additional private member functions that can be used for doing implementation work within the class. DrinkItem class The DrinkItem class will contains the following private data members: name: Drink name (type of drink – read in from a file). Type...

  • In this practice program you are going to practice creating graphical user interface controls and placing...

    In this practice program you are going to practice creating graphical user interface controls and placing them on a form. You are given a working NetBeans project shell to start that works with a given Invoice object that keeps track of a product name, quantity of the product to be ordered and the cost of each item. You will then create the necessary controls to extract the user input and display the results of the invoice. If you have any...

  • I need help solving this question from the practice final exam given to us to prepare...

    I need help solving this question from the practice final exam given to us to prepare for the final in C++ #include <iostream> using namespace std; /* The following is code for an OrderedCollection container and its related iterator. The container has a capacity determined by a constructor parameter. The container does not grow. Code that adds elements to the container ensures that the capacity of the container is never exceeded. An attempt to add an item to a full...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • I need help with this assignment, can someone HELP ? This is the assignment: Online shopping...

    I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT