Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question: You are running a book store. Your store contains ... Bookmark You are

ID: 3581648 • Letter: Q

Question

Question: You are running a book store. Your store contains ... Bookmark You are running a book store. Your store contains books in 5 subjects and each subject contains 3 books. Write a program that will print the subject of texts, cost of texts and total cost across and down. Also print the name and value of the cheapest text. In the last program you actually and read and the information 5 times, this time read and write it only once using a loop. Create a function to print your information. Pass 7 parameters to the function to print your information. The 7 parameters are: number of subject (1 for Biology, 2 for Chemistry, 3 for English, etct.), price for the 3 tets, total value, number for cheapest text, and the value for the cheapest text. Put your input in a file and print the output.

This is for C++

If you could include header files as well that would be appreciated.

Explanation / Answer

#include <iostream>
using namespace std;
void display(int, int,int,int,int,int,int);


int main()
{
   char name1[50];
    char name2[50];
    char name3[50];
    int price1;
    int price2;
    int price3;
   int minindex,subjectnum;
   int min;
   int tprice;

    //loop to reading 5 books data
    for (int i=0;i<5;i++)
    {
    subjectnum=i+1;
   cout << "Enter Details of Subject-"<<subjectnum <<endl;
    cout << "Enter Textbook-1 name: ";
    cin>>name1;
    cout << "Enter price of Textbook-1: "<<name1<<endl;
    cin >> price1;
    cout << "Enter Textbook-2 name: ";
    cin>>name2;
    cout << "Enter price of Textbook-2: "<<name2<<endl;
    cin >> price2;
    cout << "Enter Textbook-3 name: ";
    cin>>name3;
    cout << "Enter price of Textbook-3: "<<name3<<endl;
    cin >> price3;
  
    //calculation of total price
   tprice=price1+price2+price3;
   //calculation of min value and number
   if((price1<price2) && (price1<price3))
   {
    min=price1;
    minindex=1;
   }
   else if(price2<price1 && price2<price3)
   {
    min=price2;
        minindex=2;
   }
   else
   {
    min=price3;
        minindex=3;
   }
   //function call to display
   display(subjectnum,price1,price2,price3,tprice,minindex,min);
  
   }
    return 0;
}
//function defination for display output
void display(int subjectnum, int price1,int price2,int price3,int tprice,int minindex,int min) {
   // local variable declaration

cout << "Detials of subject"<<subjectnum<<endl;

cout<<"Subject1 price - "<<price1<<endl;
cout<<"Subject2 price - "<<price2<<endl;
cout<<"Subject3 price - "<<price3<<endl;
cout<<"Total price of 3 books - "<<tprice<<endl;
cout<<"Minimum cost index number among 3 books - "<<minindex<<endl;
cout<<"Minimum cost value book among 3 books - "<<min<<endl;

}

output :

Enter Details of Subject-1
Enter Textbook-1 name: a
Enter price of Textbook-1: a
100
Enter Textbook-2 name: b
Enter price of Textbook-2: b
200
Enter Textbook-3 name: c
Enter price of Textbook-3: c
300
Detials of subject1
Subject1 price - 100
Subject2 price - 200
Subject3 price - 300
Total price of 3 books - 600
Minimum cost index number among 3 books - 1
Minimum cost value book among 3 books - 100
Enter Details of Subject-2
Enter Textbook-1 name: z
Enter price of Textbook-1: z
20
Enter Textbook-2 name: c
Enter price of Textbook-2: c
46
Enter Textbook-3 name: f
Enter price of Textbook-3: f
67
Detials of subject2
Subject1 price - 20
Subject2 price - 46
Subject3 price - 67
Total price of 3 books - 133
Minimum cost index number among 3 books - 1
Minimum cost value book among 3 books - 20
Enter Details of Subject-3
Enter Textbook-1 name: e
Enter price of Textbook-1: e
12
Enter Textbook-2 name: v
Enter price of Textbook-2: v
24
Enter Textbook-3 name: g
Enter price of Textbook-3: g
47
Detials of subject3
Subject1 price - 12
Subject2 price - 24
Subject3 price - 47
Total price of 3 books - 83
Minimum cost index number among 3 books - 1
Minimum cost value book among 3 books - 12
Enter Details of Subject-4
Enter Textbook-1 name: g
Enter price of Textbook-1: g
46
Enter Textbook-2 name: h
Enter price of Textbook-2: h
89
Enter Textbook-3 name: f
Enter price of Textbook-3: f
56
Detials of subject4
Subject1 price - 46
Subject2 price - 89
Subject3 price - 56
Total price of 3 books - 191
Minimum cost index number among 3 books - 1
Minimum cost value book among 3 books - 46
Enter Details of Subject-5
Enter Textbook-1 name: k
Enter price of Textbook-1: k
78
Enter Textbook-2 name: l
Enter price of Textbook-2: l
79
Enter Textbook-3 name: h
Enter price of Textbook-3: h
90
Detials of subject5
Subject1 price - 78
Subject2 price - 79
Subject3 price - 90
Total price of 3 books - 247
Minimum cost index number among 3 books - 1
Minimum cost value book among 3 books - 78

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote