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
nordsb [41]
3 years ago
6

Input and Output. Keep the program running in a Do-While Loop or While Loop. Conditional statements. User defined functions for

most menu items. User define structs. Arrays of type your struct -- You may assume a maximum of 50 products. The program should prompt the user for the valid password – EGC251 (10 pt.) The user then should be prompted with the following menu: (10 pt.) Input new product record – prompt user for each record of a new product (20 pt.) Edit a product – display the current record item and accept a new value. This would be if you want to add more items of the same product. (20 pt.) Delete a product – remove the product from the list and rearrange the product array (20 pt.) Display all existing product – display each record on a separate line (20 pt.) Make a sale – prompt the user for the product ID and number of items sold, calculate the sale, and update the number of available items. (20 pt.) Display the product record with the highest sale – search the records to find the highest sale for a product (20 pt.) Display all product with zero quantity – search all products with zero quantity (20 pt.) Exit the program (10 pt.)
Computers and Technology
1 answer:
kolezko [41]3 years ago
3 0

Answer:

See explaination

Explanation:

#include <stdio.h>

#define MAX_SIZE 50

#define password "mypassword"

void addProduct(struct product arr[], struct product p);

void deleteProduct(struct product arr[], char[] productId)

void editProduct(struct product arr[], int incrementKey, char[] productId) //incrementKey is the how much quanity user wants to add of the existing product

void display(struct product arr[]);

void saleProduct(struct product arr[], char[] productId, int soldItems);

void displayHighestSaleProduct(struct product arr[]);

void displayProductWithZeroQuantity(struct product arr[]);

int totalItems = 0;

struct product

{

char id[10]; //product id

char name[50]; //name of product

int quantity; //number of items of product in the inventory

int numSold; //number of items sold

float price; //price of the product

float sales; //total sale

};

void saleProduct(struct product arr[], char[] productId, int soldItems)

{

int index = 0;

while(strcmp(arr[index].id, productId) != 0) //getting the index of product same as productId

index++;

arr[index].qunatity -= soldItems;

arr[index].sales += (soldItems*arr[index].price);

}

void displayProductWithZeroQuantity(struct product arr[])

{

int x = 0;

printf("Zero Quantity Product:");

for(int i=0;i<totalItems;i++)

if(arr[i].qunatity == 0)

{

printf("Id=>%s\tName=>%s\tQuantity=>%d\tNumSold=>%.2f\tPrice=>%d\tSales=>%.2f", &arr[i].id, &arr[i].name, &arr[i].quantity, &arr[i].numSold, &arr[i].price, &arr[i].sales);

x = 1;

}

if(x == 0)

printf("No product with zero quantity.");

}

void displayHighestSaleProduct(struct product arr[])

{

float max = 0.0f;

int index = 0;

for(int i=0;i<totalItems;i++)

if(arr[i].sales > max)

{

max = arr[i].sales;

index = i;

}

printf("Highest saling product:");

printf("Id=>%s\tName=>%s\tQuantity=>%d\tNumSold=>%.2f\tPrice=>%d\tSales=>%.2f", &arr[index].id, &arr[index].name, &arr[index].quantity, &arr[index].numSold, &arr[index].price, &arr[index].sales);

}

void display(struct product arr[])

{

for(int i=0;i<totalItems;i++)

{

printf("Id=>%s\tName=>%s\tQuantity=>%d\tNumSold=>%.2f\tPrice=>%d\tSales=>%.2f", &arr[i].id, &arr[i].name, &arr[i].quantity, &arr[i].numSold, &arr[i].price, &arr[i].sales);

printf("\n");

}

}

void editProduct(struct product arr[], int incrementKey, char productId[])

{

int index = 0;

while(strcmp(arr[index].id, productId) != 0) //getting the index of product same as productId

index++;

arr[index].quantity += incrementKey ;

}

void addProduct(struct product arr[], struct product p)

{

int index = 0;

while(index < totalItems)

index++;

arr[index] = p;

totalItems++;

}

void deleteProduct(struct product arr[], char[] productId)

{

int index = 0;

while(strcmp(arr[index].id, productId) != 0) //getting the index of product same as productId

index++;

for(int i = index;i<totalItems-1;i++)

arr[i] = arr[i+1] ;

totalItems--;

}

void processintChoice(int x, struct product arr)

{

switch(x)

{

case 1:

{

char id[10];

char name[50];

int quantity;

float price;

printf("\nenter the id of product:");

scanf("%s", &id);

printf("\nenter the name of product:");

scanf("%s", &name);

printf("\nenter the quantity of product:");

scanf("%d", &quantity);

printf("\nenter the price of product:");

scanf("%.2f", &price );

struct product p;

p.id = id;

p.name = name;

p.quantity = quantity;

p.price = price;

p.numSold = 0;

p.sales = 0.0f;

addProduct(arr, p);

}

case 2:

{

char str[10];

int num;

printf("enter the product id");

scanf("\n%s", &str);

printf("enter the number by which you want to increase product items.")

scanf("\n%d", &num);

editProduct(arr, num ,str);

}

case 3:

{

char p[10];

printf("enter the product id to delete product:");

scanf("\n%s", &p);

deleteProduct(arr, p);

}

case 4:

{

display(arr);

}

case 5:

{

char p[10];

int num;

printf("enter the product od to purchse:");

scanf("\n%s", &p);

printf("enter the number of items u want to purchse:");

scanf("\n%d", &num);

saleProduct(arr, p, num);

}

case 6:

{

displayHighestSaleProduct(arr);

}

case 7:

{

displayProductWithZeroQuantity(arr);

}

case 8:

{

exit(0);

}

}

}

int main()

{

struct product arr[MAX_SIZE];

char pass[10];

printf("please enter the password:")

scanf("\n%s", &pass);

if(strcmp(pass, password) == 0)

{

label:

printf("\nplease select the proper option from the below menu:");

printf("\n1.) Input new product record");

printf("\n2.) Edit a product");

printf("\n3.) delete a product");

printf("\n4.) display all existing products");

printf("\n5.) make a purchase");

printf("\n6.) display the product detail with highest sale");

printf("\n7.) display a product with zero quantity");

printf("\n8.) exit the program");

int choice;

printf("\nChoice - >");

scanf("%d", &choice);

if(choice < 1 && choice > 8 )

{

printf("Invalid Choice! please choose again");

goto label;

}

else

processChoice(choice, arr);

}

else return(0);

}

You might be interested in
1. What does the word “processing” in data pro- cessing mean?
blsea [12.9K]

Answer:

Word processing is the process of creating and editing documents on a computer. It allows a user to create documents that mimic the format and style of a typical typewriter. It requires a computer and word processing software. A printer may also be used to create a physical copy of the document.

Explanation:

6 0
2 years ago
Read 2 more answers
Lisa granted the CREATE TABLE privilege WITH ADMIN OPTION to Sharon. Sharon granted the privilege to Bob. If Lisa’s privileges a
GuDViN [60]

Answer:

D

Explanation:

As it's not fair if they all lose there privileges

4 0
3 years ago
A network of Bennetton retail sales agents select the Bennetton designs that they feel will appeal to Bennetton retail customers
denpristay [2]

Answer:

It is an example of a matrix structure

Explanation:

The matrix structure is a structure in which jurisdiction, controls and duties are carried and uphold by a group of employees instead of just the manager.

In other words, employees have dual reporting relationships; they can give reports to the functional manager and they can also give reports to the product manager.

The Bennetton design selected by the network of Bennetton retail sales agents made activities to be easily coordinated because, they have collectively performed the duty as a unit and this is one of the advantages of this form of the matrix organizational structure.

7 0
3 years ago
Read 2 more answers
13. WHICH OF THE FOLLOWING IS INVOLVED IN CREATING A DOCUMENT? *
Pavlova-9 [17]

Answer:

All of the above

Explanation:

Hope this helps...

7 0
2 years ago
How to connect canon printer to computer?
denpristay [2]
<span>Step 1Determine what type of connection you need for your computer and printer. If you see a large rectangular connection on your printer it is a parallel printer, and you will need to make sure you have a parallel port on your computer. This connection will be long and rectangular, and it may be red in color. If your Canon printer has a small square connection on the back it is a USB printer, and you will need to look for a flat slot on your computer to hook it up.Step 2Connect the printer and computer. If you are working with a parallel printer connect the large end of the cable to the back of the printer and the smaller end to the computer. If you have a USB printer, connect the square end of the cable to the back of the printer and the flat end to a free USB port on your computer.Step 3Turn on your printer and the computer. Insert the print cartridges that come with the printer. Watch the lower right-hand corner of your computer screen for a "found new hardware" message. This is your indication that the operating system has found your new printer and is installing the proper driver for it.Step 4Insert the CD that comes with your printer, if you are prompted to do so. If your operating system was unable to find a suitable driver it will prompt you for the CD. Keep your CD handy anyway, because you will need it to install the printer utilities.Step 5Insert the CD and allow it to install your printer utilities. After the utilities are installed you will be prompted to clean and align the print heads on your new printer. After the print heads have been aligned your new Canon printer will be ready for use.hope this helps</span>
7 0
2 years ago
Other questions:
  • A peripheral can be used to tell a computer to complete a specific task. True False
    15·1 answer
  • This type of connection uses radio waves to connect devices on a network.
    15·2 answers
  • How do you insert a new row into a worksheet
    5·1 answer
  • Write a program that implement a bubble sort ?
    5·1 answer
  • Which file extension takes less storage space?
    13·2 answers
  • Caleb is a big fan of science fiction, so he loves picturing the ________ gland as the captain of his personal starship, pulling
    9·1 answer
  • You are hired as an IT consultant for the government owned mobile operating company, Teletalk. Based on the following scenario,
    8·1 answer
  • क) मानौं तिमी बसेको समाजमा मान्छेहरूले सधै फोहर फाल्ने गर्नाले वातावरण प्रदूषित
    13·1 answer
  • Write a program to find the principle amount​
    10·1 answer
  • click attachment to see correct answer. Which agencies run the Landsat Program? The Landsat program is run by ___ and ___.​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!