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
All objects in an object-oriented program are instantiated (created) from a ____.
Nuetrik [128]

Answer:

Class is the correct answer for the above question.

Explanation:

In an object-oriented language, The class is a structure type template, which is used to define the structure but the class does not take memory when an object is created then it takes the memory of class type. For example, if a user-defined class of one member whose size is 4 bit if its store in memory. When a user creates an object, then the object size is 4 bit.

That's why the class is an only structure while an object is used to give the memory for class member and the member of the class also get executed by the object of that class. class have no existence if object is not created. so when a user wants to create a object, he needs to create the object by the help of class name because class is user defined data type and object is variable of that class.

Then the answer of the above question is that object is created with the help of class which is described above.

6 0
3 years ago
Targeting encourages drivers to scan far ahead and _____________. A. focus their visual attention on the next point on the road
Colt1911 [192]
<span>A. focus their visual attention on the next point on the road.  A driver must have a target, it can be the car in front, a building pr a structure on the road.  Targeting enables the driver to look further ahead on the road and thus be ready for any obstacle on the road.</span>
3 0
3 years ago
Read 2 more answers
Your task is to identify three or more ways that big data is being collected on a regular basis, including one data collection m
attashe74 [19]

Answer:

Data is one of the most valuable resources today's businesses have. ... There are various data-gathering methods you can use with the help of your ... When it comes to data businesses collect about their customers, ... Third-party data offers much more scale than any other type of data, ... Big White Cursor.

Explanation:

4 0
2 years ago
The buttons on a specific tab are organized into logical Ribbons. <br> T<br> F
NeTakaya
I believe the answer would be true
8 0
2 years ago
Read 2 more answers
Your organization recently deployed a Windows domain controller with Active Directory. All the domain OU users need to run the s
liberstina [14]

<u>Normally windows end user can login 3 ways as follow:</u>

1. End user can Login as local account where user has not connected or even connected to local Area network LAN.

2. Next user can login into cloud accounts nothing but hot mail  accounts

3. Login to windows domain controller where end user should connect to LAN.

Purpose of installation of Windows domain controller with Active Directory is to keep trace and keep log history activities.

Due to windows domain controller with Active Directory end user desktop or laptop has control on software access also.

Every time when end user login on windows domain controller a small modified is executed whenever is required. It is not going effort the workstation performances.

Note: - Domain severs should be POWER on first.

5 0
3 years ago
Other questions:
  • You’ve received a tarball called data79.tar from a colleague, but you want to check the names of the files it contains before ex
    15·1 answer
  • Reflexes are basically "hard-wired" into the CNS. Anatomically, the basis of a reflex is an afferent neuron that synapses direct
    10·1 answer
  • Use this option to view your presentation as your audience will see it. a.File menu b.Play button c.Slide Show button d.Tools me
    6·2 answers
  • Bitnet, one of the predecessors of the internet was launched in 1981. what does bitnet stand for?
    12·1 answer
  • The desktops of computers running the same OS all look the same
    8·1 answer
  • 3. The invention of the transistor was important to the development of computers because it
    5·1 answer
  • Beth would like to run an nmap scan against all of the systems on her organization's private network. These include systems in t
    15·1 answer
  • 16 to 19 year old drivers are how many more times likely to crash? 1.7,2.7,0.7 ,3.7
    12·2 answers
  • A high school in a low-income area offers special programs to help students acquire the technical skills needed to find jobs as
    12·1 answer
  • How do I delete my brainly account?<br> I don't need anymore.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!