CENG 112 Assignment 1 to 4 solutions

$90.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

CENG 112 Assignment 1: The Shopping App

This assignment covers the topics of: ● Strings ● Arrays ● File I/O ● ADTs ● Generics ● Bags You are expected to implement “The Shopping App” using Java. In the app, the user has a fridge to fill and she/he can go to the mall to buy groceries. When the user goes to the mall to shop, she/he has a basket with a size of 2000 grams. The user adds products to the basket. During shopping, the user can check the items that are in the basket already.

If an item that the user selects cannot be added to the basket because of exceeding the basket capacity, your program should print a warning message. Shopping is finished when the user enters finish shopping, or the basket is full. The items in the inventory of the mall are listed together in “inventory.txt” file where each line is formed as: item_name,item_compartment,item_weight(grams)

After finishing shopping, the user heads home to fill her/his fridge. The fridge has four compartment with their limited size: [0] Vegetables and Fruits 3000 grams [1] Meats 5000 grams [2] Beverages 4000 grams [3] Snacks 2000 grams Each item has to be put into their corresponding compartment. During the program run, you should be able to check the status of the fridge (remaining capacities of each compartment).

If some of the items cannot be put to their corresponding compartments according to their remaining capacity, your program has to print a warning message. (e.g. If the remaining capacity of Vegetables and Fruits is 200 grams and you try to add a tomato to the fridge, the program should print a message like “tomato cannot be added to the fridge”). After filling the fridge, the user can go shopping again, and return back to fill her/his fridge.

Your program should end when the user enters exit, or all compartments are full. Your code must have the interface, class and method implementations given below.The bullets (I), (C), and (M) stand for interface, class, method respectively. I. IBag M. public boolean add(T newItem); M. public boolean isEmpty(); M. public boolean isFull(); M. public T removeByIndex(int index); M. public T remove(); M. public T remove(T item); M. public int getItemCount(); M. public int getIndexOf(T item); M. public boolean contains(T item); M. public void displayItems(); M. public void dump(); // removes all the items from the bag M. public boolean transferTo(IBag targetBag, T item); C. ShoppingApp M. public static void main(String[] args); C. FileIO M. public static InventoryBag readInventory(); C. Item M. public String toString(); M. public boolean equals(Object obj); C. ShoppingBasket implements IBag C.

MeatsCompartment implements IBag C. VegetablesFruitsCompartment implements IBag C. BevaragesCompartment implements IBag C. SnacksCompartment implements IBag p.s. You can add more classes and methods to your program according to your design. NOTE: While implementing your program please make sure that your program is user friendly. Try to make your user inputs simpler. For example, in a selection process rather than asking the user to write or type a long string, make the selections with numbers.

Assignment Rules

● This is a group assignment (2 students). However, inter-group collaboration is not allowed! ● All assignments are subject to plagiarism detection and the suspected violations (the solutions derived from or inspired by the solution of other groups) cause to be graded as zero. ● It is not allowed to use Java Collections Framework.

● Your code should be easy to read and test: – Keep your code clean. Avoid duplication and redundancy. – Follow Java Naming Conventions. – Use relative paths instead of absolute ones.

Submission Rules All submissions must: ● be performed on Microsoft Teams by only one of the group members, ● be performed before the deadline, ● be exported as an Eclipse Project and saved in ZIP format, ● include all necessary data files (txt, csv, json, etc.) in the right directory, ● follow a specific naming convention such that CENG112_HW1_groupID. Eclipse Project: CENG112_HW1_G5 Exported Archive File: CENG112_G5.zip Submissions that do not comply with the rules above are penalized.

CENG 112 Assignment 2: Furniture Manufacturing and Ordering System

In this homework, you are expected to implement a “Furniture Manufacturing and Ordering
System” application using Java. This homework will cover the topics given below;
1. Strings, Arrays, Generics
2. Queue ADT (Abstract Data Type)
3. Stack ADT (Abstract Data Type)

Assume that you are a Furniture Manufacturer called “IZTECHEA”, that manufactures
different types of furniture. However, you immediately manufacture furniture according to the
order that comes from your Marketing Analyst and you store it in one factory line that is
based on a First-In-First-Out (FIFO) structure. Marketing Analyst randomly generates what
to be produced and sends the request to the “IZTECHEA”.

Your factory manufactures 6
different types of products, where all of them must implement the IProduct interface;
1. Sofa
2. Bed
3. Chair
4. Dresser
5. Table
6. Bookcase
The methods for interface IProduct is given below:
public interface IProduct {
public boolean isManufactured();
public boolean isStored();
public boolean isSold();
}

When you manufacture a product, it is temporarily stored in the factory (production line) until
the Storage Chief moves (i.e., “stores”) it into a warehouse. Note that, at each request, the
Storage Chief takes one product from the factory line, i.e. queue, and stores each product
in its own warehouse. Thereby, you will have six warehouses. The warehouses are
designed to retrieve the first product that has been recently added to your warehouse. In
other words, furniture is stored in Last-In-First-Out (LIFO) order.

When a customer comes to buy any furniture, that furniture is decided randomly, and a
customer request is formed accordingly. Based on the requested furniture, you find the
corresponding warehouse and remove/pop it from the warehouse to sell it to the customer. If
you don’t have the requested product in the respective warehouse, you should return a FAIL
message. If you have it, you should return a SUCCESS message. FAIL and SUCCESS
messages work in the same way for the marketing analyst and storage.

Write a simulation that randomly receives requests from Marketing Analyst, Storage Chief,
and Customer. There is only one object representing each role. You should only ask the
user to enter a single input that is the number of requests for the simulation. After all
the requests are completed, you should print a report that shows the number of products in
the factory, in the warehouse, and that is sold.

The main structure of the program is given as a pseudocode:
r1 chooses among Marketing Analyst, Storage Chief and Customer.
r2 chooses among Sofa, Bed, Chair, Dresser, Table, Bookcase.
Input number of requests
products[] {Sofa, Bed, Chair, Dresser, Table, Bookcase}
from 1 to number of requests
select a random number r1 in [0,2] # 3 roles (i.e. activities)
if r1 = 0
select a random number r2 in [0,5] # 6 types of furniture
product = products[r2]
trigger Marketing Analyst for product
endif
if r1 = 1
trigger Storage Chief
endif
if r1 = 2
select a random number r2 between 0-5 # 6 types of furniture
product = products[r2]
trigger Customer for product
endif
product = null
end

An example input/output is given below:
Enter the number of random request cycles: 13
1. Customer buying Table, FAIL, Table warehouse empty
2. Marketing Analyst requesting Bed, SUCCESS, Bed manufactured
3. Marketing Analyst requesting Bed, SUCCESS, Bed manufactured
4. Customer buying Bed, FAIL, Bed warehouse empty
5. Marketing Analyst requesting Sofa, SUCCESS, Sofa manufactured
6. Storage Chief storing Bed, SUCCESS, Bed stored in Bed warehouse

7. Storage Chief storing Bed, SUCCESS, Bed stored in Bed warehouse
8. Customer buying Bed, SUCCESS, Customer bought Bed
9. Storage Chief storing Sofa, SUCCESS, Sofa stored in Sofa warehouse
10. Marketing Analyst requesting Chair, SUCCESS, Chair manufactured
11. Storage Chief storing Chair, SUCCESS, Chair stored in Chair warehouse
12. Customer buying Chair, SUCCESS, Customer bought Chair
13. Marketing Analyst requesting Sofa, SUCCESS, Sofa manufactured

REPORT:
Amount of Bed in Factory Line: 0
Amount of Sofa in Factory Line: 1
Amount of Dresser in Factory Line: 0
Amount of Table in Factory Line: 0
Amount of Chair in Factory Line: 0
Amount of Bookcase in Factory Line: 0
Amount of Bed in Bed Warehouse: 1
Amount of Sofa in Sofa Warehouse: 1
Amount of Dresser in Dresser Warehouse: 0
Amount of Table in Table Warehouse: 0
Amount of Chair in Chair Warehouse: 0
Amount of Bookcase in Bookcase Warehouse: 0
Amount of Bed Sold: 1
Amount of Sofa Sold: 0
Amount of Dresser Sold: 0
Amount of Table Sold: 0
Amount of Chair Sold: 1
Amount of Bookcase Sold: 0

Assignment Rules

● This is a group assignment (2 students). However, inter-group collaboration is not allowed!
● All assignments are subject to plagiarism detection and the suspected violations (the solutions
derived from or inspired by the solution of other groups) cause to be graded as zero.
● It is not allowed to use Java Collections Framework.
● Your code should be easy to read and test:
– Keep your code clean. Avoid duplication and redundancy. 🔗
– Follow Java Naming Conventions. 🔗
– Use relative paths instead of absolute ones. 🔗

Submission Rules
All submissions must:
● be performed via Microsoft Teams by only one of the group members,
● be performed before the deadline,
● be exported as an Eclipse Project and saved in ZIP format,
● include all necessary data files (TXT, CSV, JSON, etc.) in the right directory,
● follow a specific naming convention such that CENG112_HW2_groupID.
Eclipse Project: CENG112_HW2_G5
Exported Archive File: CENG112_HW2_G5.zip

Submissions that do not comply with the rules above are penalized.
NOTE: Those who want to change groups can send their requests on Microsoft Teams.

CENG 112 Assignment 3: Operating System Process Management Simulation

In this homework, you are expected to implement a basic “Operating System
Process Management Simulation” application using Java. This homework will cover
the topics given below:
1. Linked Lists
2. List ADT (Abstract Data Type)
3. Priority Queue ADT (Abstract Data Type)

Assume that you are designing a process management system for an operating
system. In this system, different processes with various priorities “request”
computing time from the operating system. Only one process can be computed at a
given time. In other words, there is no parallel computing.

There are three types of process in the system:
1. High → Priority: 1
2. Normal → Priority: 2
3. Low → Priority: 3

At any given time system can have different number of processes. The systems
should keep all the processes in a list.
The Process class should implement the following IProcess interface:
public interface IProcess {
public String getType();
public int getPriority();
public String toString();

}

You can assume that all processes request computation at the same time. The
computations should be placed in a queue-based structure with a FIFO approach
with priorities.

In this system, each “computation” has an occupation time that denotes how many
nanoseconds the operating system will be occupied. Your application should keep
statistics about the estimated waiting time for each process, and this waiting time is
equal to the sum of occupation time of all prior computations.

An outline of the Computation class is given below:
public Computation {
private int id;
private IProcess process;
private int occupation;
public String toString();
… // Constructors, getter setter and
other helper methods
}
// unique computation id in [1,1000]
// the process that makes computation request
// needed time for the computation

You are expected to create 3 simulations. Each simulation should have 3, 5, and 10
random processes respectively. Furthermore, for each simulation there should be a
corresponding priority computation queue. The simulations should be connected to
each other in a linked list fashion.

Your application should print some statistics at the end of each simulation which are:
● Simulation Number
● Representation of the Computation Queue
● Total number of computations for the simulation
● Total and average waiting times
● Total number of computations for each specific type of process
● Total and average waiting time for each specific type of process

Summary of the Requirements

1. Create 3 simulations (which are linked to each other) with 3,5, and 10 random
processes.
2. Place processes in a list for each simulation.
3. Create a “computation queue” for each simulation in which each computation
should have a random occupation time (between 1-10ns).
4. For each simulation, print statistics.

The output of your program for the first simulation should look something like this:
Simulation Number: 1
Computation Queue: P2,High,10ns ← P1,High,2ns ← P3,Low,7ns
Total numbers of computations : 3
Total waiting time: 12
Average waiting time: 4
Total number of computations for High: 2
Total number of computations for Normal: 0
Total number of computations for Low: 1
Total waiting time for High: 10
Average waiting time for High: 5
Total waiting time for Normal: 0
Average waiting time for Normal: 0
Total waiting time for Low: 12
Average waiting time for Low: 12
….
You should print this output for each simulation.

Assignment Rules

● This is a group assignment (2 students). However, inter-group collaboration is not allowed!
● All assignments are subject to plagiarism detection and the suspected violations (the solutions
derived from or inspired by the solution of other groups) cause to be graded as zero.
● It’s not allowed to use Java Collections Framework.
● Your code should be easy to read and test:
– Keep your code clean. Avoid duplication and redundancy. 🔗
– Follow Java Naming Conventions. 🔗
– Use relative paths instead of absolute ones. 🔗

Submission Rules
All submissions must:
● be performed via Microsoft Teams by only one of the group members,
● be performed before the deadline,
● be exported as an Eclipse Project and saved in ZIP format,
● include all necessary data files (TXT, CSV, JSON, etc.) in the right directory,
● follow a specific naming convention such that CENG112_HW3_groupID.
Eclipse Project: CENG112_HW3_G5
Exported Archive File: CENG112_HW3_G5.zip

Submissions that do not comply with the rules above are penalized.
NOTE: Those who want to change groups can send their requests on Microsoft Teams.

CENG 112 Assignment 4: Food Delivery Application

In this homework, you are expected to implement a “Food Delivery Application” using Java.
This homework will cover the topics given below:
1) Generics, Interfaces
2) Queue ADT, Stack ADT
3) Iterators, Comparators
4) Binary Search Trees

Assume that you are designing a food delivery application that runs as a marketplace for
local restaurants. The restaurants and foods are placed in several binary search trees with
respect to different attributes such as price, stock, restaurant rating, and delivery time.
Implement a Restaurant class that includes but is not limited to:
public class Restaurant {
private String name
private double rating
private String cuisine
private int deliveryTime // in minutes
public void updateCuisine(String category)
public void updateRating(double score)
public void updateDeliveryTime(int deliveryTime)
… // Constructors, getters, setters and other methods
}
Implement the Orderable interface that includes but is not limited to:
public interface Orderable {
public void updatePrice(double price)
public void updateStock(int stock)
… // Other method names if needed
}
Implement a Food class that includes but is not limited to:
public class Food implements Orderable … // other interfaces if needed
{
private String name
private double price
private int stock
private Restaurant restaurant
… // Constructors, getters, setters and other methods
}

You are expected to read restaurant and food data from CENG112_HW4.csv file where each
line is formed as:
fName, fPrice, fStock, rName, rRating, rCuisine, rDelivery
Note that the initial letters “f” and “r” represent food and restaurant attributes, respectively.
You should assume that restaurant names are unique and create only one instance if there
are multiple restaurants with the same name in the CSV file. In other words, before adding a
new restaurant into the BST, check if it already exists.

Perform the following operations step-by-step:
1) List the names and ratings of the restaurants in descending order of rating.
2) List the names, prices, and stocks of the food in ascending order of price.
3) Print the name of the Pizza restaurant that has the shortest delivery time.
4) Print the name of the Coffee with the highest amount of stock.

5) List and remove the foods (from Food BST) that are more expensive than 80 TRY.
6) List and remove the restaurants (from Restaurant BST) that are rated less than 8.0.
7) Increase all food prices by 20% (use the updatePrice method).
8) Cut all food stocks by half (use the updateStock method).
9) List the names and ratings of the restaurants in descending order of rating. (Like Step 1).
10) List the names, prices, and stocks of the food in ascending order of price. (Like Step 2).

Assignment Rules

● This is a group assignment (2 students). However, inter-group collaboration is not allowed!
● All assignments are subject to plagiarism detection and the suspected violations (the solutions
derived from or inspired by the solution of other groups) cause to be graded as zero.
● It is not allowed to use Java Collections Framework.
● Your code should be easy to read and test:
– Keep your code clean. Avoid duplication and redundancy. 🔗
– Follow Java Naming Conventions. 🔗
– Use relative paths instead of absolute ones. 🔗

Submission Rules
All submissions must:
● be performed via Microsoft Teams by only one of the group members,
● be exported as an Eclipse Project and saved in ZIP format,
● include all necessary data files (TXT, CSV, JSON, etc.) in the right directory,
● follow a specific naming convention such that CENG112_HW4_groupID.
Eclipse Project: CENG112_HW4_G5
Exported Archive File: CENG112_HW4_G5.zip

Submissions that do not comply with the rules above are penalized.
Those who want to change groups can send their requests on Microsoft Teams.