Write a program to keep track of the inventory of grocery store.
Write a test program that prompts the user to enter how many items of inventory the store has. After that enter item name, quantity and price of each item in three different arrays called Itemname, Quantity and Price.
Than calculate the Total=Quantity*Price of items in store and FinalTotal of all the items and print in following exact format using array:
Sample run of program:
Enter number of items to store in array: 3
Enter quantity of item: 10
Enter price of item: 5.0
Enter item name: Mouse
Enter quantity of item: 20
Enter price of item: 10.0
Enter item name: Keyboard
Enter quantity of item: 5
Enter price of item: 20.0
Enter item name: Usb
ItemName Quantity
Unit Price
Total
Mouse 10.00
$5.00
$50.00
Keyboard 20.00
$10.00
$200.00
Usb
5.00
$20.00 $100.00
FinalTotal
$350.00
The answer to this question is as follows:
The code is as follows:
import java.util.*;
public class MyClass {
public static void main(String args[]) {
int number_of_items;
double quantity,price_per_item,total=0.0;
String item_name;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number of items to store in
array:");
number_of_items=sc.nextInt();
ArrayList<Double> quantity_list = new
ArrayList<Double>(number_of_items);
ArrayList<Double> price_list = new
ArrayList<Double>(number_of_items);
ArrayList<String> item_list = new
ArrayList<String>(number_of_items);
for(int i=0;i<number_of_items;i++)
{
System.out.print("\nEnter quantity of item:");
quantity=sc.nextDouble();
System.out.print("\nEnter price of item:");
price_per_item=sc.nextDouble();
System.out.print("\nEnter item Name:");
item_name=sc.nextLine();
quantity_list.add(quantity);
price_list.add(price_per_item);
item_list.add(item_name);
}
System.out.print("\n ItemName\t\t Quantity\t\t\t Unit Price
\tTotal\n");
for (int i=0; i<number_of_items; i++)
{
System.out.print(item_list.get(i)+"\t\t\t");
System.out.print(quantity_list.get(i)+"\t\t\t\t");
System.out.print("$"+price_list.get(i)+"\t\t\t ");
System.out.print("$"+quantity_list.get(i)*price_list.get(i)+"\t\t\t\t");
System.out.println();
total=total+quantity_list.get(i)*price_list.get(i);
}
System.out.print(" FinalTotal\t\t\t$"+total);
}
}
The input and output are provided in the screenshot below:
Write a program to keep track of the inventory of grocery store. Write a test program...
Problem 1: Dynamic Grocery Array Using Java to write a program that prompts the user to enter an item’s name for each position in the array. The program then prints uses a loop to output the array. Example 1: Banana 2: Orange 3: Milk 4: Carrot 5: Chips Banana, Orange, Milk, Carrot, Chips Problem 2: Print Characters in String Array Declare a string array of size 5. Prompt the user enters five strings that are stored in the array....
please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...
Write a C program that takes inventory data from a file and loads a structure of up to 100 items defined as: struct item { int item_number; char item_name[20]; char item_desc[30]; float item_price; } I called mine: struct item inventory[100]; (you may use any name you wish) I will let you decide the appropriate prompts and edit messages. You will read the data from the data file and store the info in an array. Assume no more than 100 records...
Write a program that stores the weekly (Monday thru Friday) sales totals for three salespersons. Your program should allow the user to enter the sales amounts and print a sales report with headings, the daily totals for each salesperson (your two-dimensional array), the calculated weekly totals for each sales person and the calculated totals for the day of each salesperson. In addition, create a single-dimensional array of Strings representing the days of the week (Monday-Friday) using an initializer list. Your...
Ch 7 Program: Online shopping cart (continued) (Java)This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).(1) Extend the ItemToPurchase class per the following specifications:Private fieldsstring itemDescription - Initialized in default constructor to "none"Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt)Public member methodssetDescription() mutator & getDescription() accessor (2 pts)printItemCost() - Outputs the item name followed by the quantity, price, and subtotalprintItemDescription() - Outputs the...
In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...
Write a python program that executes the following conditions: A store owner keeps a record of daily cash transactions in a text file. Each line contains three items: The invoice number, the cash amount, and the letter P if the amount was paid or R if it was received. Items are separated by spaces. Write a program that prompts the store owner for the amount of cash at the beginning and end of the day, and the name of the...
Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...
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...
Name : StarryArrays Write a program called StarryArrays which prompts user for the number of items in an array (a non-nega- tive integer), and saves it in an int variable called numltems. It then prompts user for the values of all the items (non-negative integers) and saves them in an int array called items. The program shall then print the contents of the array in a graphical form, with the array index and values represented by number of stars For...