Knowee
Questions
Features
Study Tools

Write a C program to store the Item number, quantity sold, and Price of one item in toi.remctf file by reading values from the keyboard.Save your program as lBQ4a.cSample inputItem number quantity sold Price of oneitem(Rs)Ilo 2 12000233 6 5000320 2 10000100 5 1500b) Write a program to read the details from i.femft£ 5°/o discount is given if more than 3 itemsare purchased from an item. Display the total amount paid for each item.` Display the itemnumber and the total amount paid for each item.Save your program as lBQ4b.cSample outputItem No. Total AmountIlo233320loo24000.0028500.0020000.007125.00

Question

Write a C program to store the Item number, quantity sold, and Price of one item in toi.remctf file by reading values from the keyboard.Save your program as lBQ4a.cSample inputItem number quantity sold Price of oneitem(Rs)Ilo 2 12000233 6 5000320 2 10000100 5 1500b) Write a program to read the details from i.femft£ 5°/o discount is given if more than 3 itemsare purchased from an item. Display the total amount paid for each item.` Display the itemnumber and the total amount paid for each item.Save your program as lBQ4b.cSample outputItem No. Total AmountIlo233320loo24000.0028500.0020000.007125.00

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is the solution for your problem.

a) The C program to store the Item number, quantity sold, and Price of one item in toi.remctf file by reading values from the keyboard.

#include<stdio.h>

struct Item {
    int itemNumber;
    int quantitySold;
    float price;
};

int main() {
    FILE *fp;
    struct Item item;
    fp = fopen("toi.remctf", "w");
    if(fp == NULL) {
        printf("File cannot be opened");
        return 1;
    }
    printf("Enter item number, quantity sold and price: ");
    scanf("%d %d %f", &item.itemNumber, &item.quantitySold, &item.price);
    fprintf(fp, "%d %d %.2f\n", item.itemNumber, item.quantitySold, item.price);
    fclose(fp);
    return 0;
}

b) The C program to read the details from toi.remctf file and calculate the total amount paid for each item.

#include<stdio.h>

struct Item {
    int itemNumber;
    int quantitySold;
    float price;
};

int main() {
    FILE *fp;
    struct Item item;
    float totalAmount;
    fp = fopen("toi.remctf", "r");
    if(fp == NULL) {
        printf("File cannot be opened");
        return 1;
    }
    while(fscanf(fp, "%d %d %f", &item.itemNumber, &item.quantitySold, &item.price) != EOF) {
        totalAmount = item.quantitySold * item.price;
        if(item.quantitySold > 3) {
            totalAmount *= 0.95; // 5% discount
        }
        printf("Item No. %d Total Amount %.2f\n", item.itemNumber, totalAmount);
    }
    fclose(fp);
    return 0;
}

Please replace "toi.remctf" with your actual file path.

This problem has been solved

Similar Questions

Write a program to enter the names of books and their prices as inputs in a Dictionary. Perform the following operations for the purchase of the books by the customer.·       Add more details of books to the dictionary·       For books priced above 1000-2999 provides a discount of 5%·       For books that are priced above 3000- 5000 provide a discount of 3% on the purchase·       For books above 5000 provides a discount of 2%.·       Books priced below 500 no discount is provided.Input format :The input consists of the book name and price.Then the choice (1 to enter more and 0 to stop).Output format :The output prints the initial and the final dictionary based on the conditions.Refer sample input and output for the formatting specifications.Sample test cases :Input 1 :Applies Stat25001Neural Networks60000Output 1 :[('Applies Stat', 2500), ('Data science Python projects', 300), ('Handbook Statistics', 18000), ('Hands on data science', 1160), ('Machine Learning', 4000), ('Neural Networks', 6000), ('Python and R', 7215)][('Applies Stat', 2375.0), ('Data science Python projects', 300), ('Handbook Statistics', 17640.0), ('Hands on data science', 1102.0), ('Machine Learning', 3880.0), ('Neural Networks', 5880.0), ('Python and R', 7070.7)]Input 2 :Applies Stat25001Neural Networks60001Artificial Intelligence52001Computer Networks25000Output 2 :[('Applies Stat', 2500), ('Artificial Intelligence', 5200), ('Computer Networks', 2500), ('Data science Python projects', 300), ('Handbook Statistics', 18000), ('Hands on data science', 1160), ('Machine Learning', 4000), ('Neural Networks', 6000), ('Python and R', 7215)][('Applies Stat', 2375.0),

write a java program to define a class Item having item namepricequantityfind the total cost of the itemuse accept method to get the data from the user and toString method to display the detailscreate two objects and display the name of the item which is ordered more quantitydisplay total amount of items purchased.edited 10:37 AM

Single File Programming QuestionProblem StatementLilly went shopping with a budget of Rs. 10,000 to buy clothes, and accessories. The cost of clothes is twice the value of accessories, and there is an additional expense of Rs. 1000 for fuel. Develop an expense calculator by inputting the amount spent on accessories, then calculate and display Lilly's remaining amount rounded to two decimal places after her shopping.ExampleInput:2000.0Output:3000.0Explanation:budget = 10000.0;fuel = 1000.0;accessories = 2000.0clothes = 2 * accessories = 2 * 2000 = 4000.0total = clothes + accessories + fuel = 4000.0 + 2000.0 + 1000.0 = 7000.0remaining = budget - total = 10000.0 - 7000.0 = 3000.0Input format :The input consists of a float value a, representing the amount spent on accessories.Output format :The output prints the remaining budget after shopping, rounded to two decimal places in the following format: "Rs. [remaining amount]". Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:10.0 ≤ a ≤ 3000.0Sample test cases :Input 1 :10.0Output 1 :Rs. 8970.00Input 2 :2000.0Output 2 :Rs. 3000.00Input 3 :3000.0Output 3 :Rs. 0.00Input 4 :1578.89Output 4 :Rs. 4263.33

Single File Programming QuestionProblem StatementMaria loves shopping and is curious to know the total cost of her favorite items. She intends to purchase t items, each priced at p rupees, with a progressive increase of 5 rupees for every subsequent item.Write a program that takes the price of one item (p) and the number of items (t) as input, calculates the total cost using the formula (t/2) * (2p + (t-1) * 5), and displays the result.Input format :The first line of input consists of a float value p, representing the price of an item.The second line of input consists of an integer t, representing the number of items.Output format :The output displays "Rs. " followed by a float value, representing the total cost in rupees, rounded off to two decimal places.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:10.0 ≤ p ≤ 1000.01 ≤ t ≤ 100Sample test cases :Input 1 :10.03Output 1 :Rs. 45.00Input 2 :720.056Output 2 :Rs. 48020.00

In  a retail store software , get the price of each stock as input with its price and print in the following format input:dinnerset10000mattress24000Invertor30000 output: dinnerset10,000mattress24,000Invertor30,000

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.