Hello.
I need to record a video, a maximum of 4 minutes. In this video, you need to explain the different parts of the code you have written, the functions, the pointers, memory allocation, memory management, and encryption methods, and if available the decryption methods must be explained verbally. The steps you are taking in explaining your written code must follow the steps, line by line, of your main function. This video should clarify the approaches you have taken along with the fulfillment of the requirements of this project.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Define the encryption methods for each item category
int encrypt_method[] = { 1, 2, 1, 3, 3, 5, 5, 5, 6, 7, 7, 4 };
// Define the durable life period for each item category in days
int life_period[] = { 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130 };
// Define the sale promotion percentage for each item category
int promotion[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// Define the regular price for each item category
float regular_price[] = { 12.50, 10.20, 8.75, 6.99, 18.99, 15.55, 11.79, 9.99, 7.25, 5.49, 13.99, 23.99 };
// Define the items bought by the customer
int bought_items[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
// Define the items returned by the customer
int returned_items[] = { 3, 7, 11 };
int main()
{
char barcode[20];
int i, j;
float price, sale_price, total_price = 0.0;
// Generate barcodes for each item and print the receipt
printf("Receipt:\n");
for (i = 0; i < 12; i++) {
// Encrypt the barcode using the appropriate encryption method
switch (encrypt_method[i]) {
case 1:
sprintf(barcode, "ABC%d", bought_items[i]);
break;
case 2:
sprintf(barcode, "DEF%d", bought_items[i]);
break;
case 3:
sprintf(barcode, "GHI%d", bought_items[i]);
break;
case 4:
sprintf(barcode, "JKL%d", bought_items[i]);
break;
case 5:
sprintf(barcode, "MNO%d", bought_items[i]);
break;
case 6:
sprintf(barcode, "PQR%d", bought_items[i]);
break;
case 7:
sprintf(barcode, "STU%d", bought_items[i]);
break;
default:
sprintf(barcode, "UNK%d", bought_items[i]);
break;
}
// Calculate the sale price of the item based on the promotion percentage
sale_price = regular_price[i] * (1 - promotion[i] / 100.0);
// Check if the item was returned and adjust the total price accordingly
for (j = 0; j < 3; j++) {
if (returned_items[j] == bought_items[i]) {
total_price -= sale_price;
break;
}
}
// Add the sale price of the item to the total price
total_price += sale_price;
// Print the barcode and sale price of the item
printf("%s %.2f\n", barcode, sale_price);
}
// Print the total price of the items purchased
printf("Total: %.2f\n", total_price);
// Print the total price of the items bought
printf("Total price: $%.2f\n", total_price);
// Get user input for product information
char name[50];
char category;
char manufacturer[50];
float purchased_price;
sale_price;
int quantity;
char purchase_date[11];
char production_date[11];
char expiry_date[11];
int store_code;
char currency[4];
printf("\nEnter the name of the product: ");
scanf("%s", name);
printf("Enter the category: ");
scanf(" %c", &category);
printf("Enter the company/manufacturer name: ");
scanf("%s", manufacturer);
printf("Enter the purchased price: ");
scanf("%f", &purchased_price);
printf("Enter the sale price: ");
scanf("%f", &sale_price);
printf("Enter the quantity of purchased items: ");
scanf("%d", &quantity);
printf("Enter the date of purchase (yyyy-mm-dd): ");
scanf("%s", purchase_date);
printf("Enter the date of production (yyyy-mm-dd): ");
scanf("%s", production_date);
printf("Enter the expiry date (yyyy-mm-dd): ");
scanf("%s", expiry_date);
printf("Enter the store code: ");
scanf("%d", &store_code);
printf("Enter the currency of the country: ");
scanf("%s", currency);
// Encrypt the necessary fields to generate the barcode
// Print the barcode
printf("Barcode: %s\n", barcode);
// Determine the discount and print the tag color
float discount_percentage = (1.0 - (sale_price / purchased_price)) * 100.0;
if (discount_percentage > 20) {
printf("Tag color: Red\n");
}
else if (discount_percentage > 10) {
printf("Tag color: Yellow\n");
}
else {
printf("Tag color: Green\n");
}
return 0;
}
Hello.
I need to record a video, a maximum of 4 minutes. In this video, you need to explain the different parts of the code you have written, the functions, the pointers, memory allocation, memory management, and encryption methods, and if available the decryption methods must be explained verbally. The steps you are taking in explaining your written code must follow the steps, line by line, of your main function. This video should clarify the approaches you have taken along with the fulfillment of the requirements of this project.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Define the encryption methods for each item category
int encrypt_method[] = { 1, 2, 1, 3, 3, 5, 5, 5, 6, 7, 7, 4 };
// Define the durable life period for each item category in days
int life_period[] = { 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130 };
// Define the sale promotion percentage for each item category
int promotion[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// Define the regular price for each item category
float regular_price[] = { 12.50, 10.20, 8.75, 6.99, 18.99, 15.55, 11.79, 9.99, 7.25, 5.49, 13.99, 23.99 };
// Define the items bought by the customer
int bought_items[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
// Define the items returned by the customer
int returned_items[] = { 3, 7, 11 };
int main()
{
char barcode[20];
int i, j;
float price, sale_price, total_price = 0.0;
// Generate barcodes for each item and print the receipt
printf("Receipt:\n");
for (i = 0; i < 12; i++) {
// Encrypt the barcode using the appropriate encryption method
switch (encrypt_method[i]) {
case 1:
sprintf(barcode, "ABC%d", bought_items[i]);
break;
case 2:
sprintf(barcode, "DEF%d", bought_items[i]);
break;
case 3:
sprintf(barcode, "GHI%d", bought_items[i]);
break;
case 4:
sprintf(barcode, "JKL%d", bought_items[i]);
break;
case 5:
sprintf(barcode, "MNO%d", bought_items[i]);
break;
case 6:
sprintf(barcode, "PQR%d", bought_items[i]);
break;
case 7:
sprintf(barcode, "STU%d", bought_items[i]);
break;
default:
sprintf(barcode, "UNK%d", bought_items[i]);
break;
}
// Calculate the sale price of the item based on the promotion percentage
sale_price = regular_price[i] * (1 - promotion[i] / 100.0);
// Check if the item was returned and adjust the total price accordingly
for (j = 0; j < 3; j++) {
if (returned_items[j] == bought_items[i]) {
total_price -= sale_price;
break;
}
}
// Add the sale price of the item to the total price
total_price += sale_price;
// Print the barcode and sale price of the item
printf("%s %.2f\n", barcode, sale_price);
}
// Print the total price of the items purchased
printf("Total: %.2f\n", total_price);
// Print the total price of the items bought
printf("Total price: $%.2f\n", total_price);
// Get user input for product information
char name[50];
char category;
char manufacturer[50];
float purchased_price;
sale_price;
int quantity;
char purchase_date[11];
char production_date[11];
char expiry_date[11];
int store_code;
char currency[4];
printf("\nEnter the name of the product: ");
scanf("%s", name);
printf("Enter the category: ");
scanf(" %c", &category);
printf("Enter the company/manufacturer name: ");
scanf("%s", manufacturer);
printf("Enter the purchased price: ");
scanf("%f", &purchased_price);
printf("Enter the sale price: ");
scanf("%f", &sale_price);
printf("Enter the quantity of purchased items: ");
scanf("%d", &quantity);
printf("Enter the date of purchase (yyyy-mm-dd): ");
scanf("%s", purchase_date);
printf("Enter the date of production (yyyy-mm-dd): ");
scanf("%s", production_date);
printf("Enter the expiry date (yyyy-mm-dd): ");
scanf("%s", expiry_date);
printf("Enter the store code: ");
scanf("%d", &store_code);
printf("Enter the currency of the country: ");
scanf("%s", currency);
// Encrypt the necessary fields to generate the barcode
// Print the barcode
printf("Barcode: %s\n", barcode);
// Determine the discount and print the tag color
float discount_percentage = (1.0 - (sale_price / purchased_price)) * 100.0;
if (discount_percentage > 20) {
printf("Tag color: Red\n");
}
else if (discount_percentage > 10) {
printf("Tag color: Yellow\n");
}
else {
printf("Tag color: Green\n");
}
return 0;
}