You are running a book store. Your store contains books in 5 subjects and each s
ID: 3581403 • Letter: Y
Question
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.
Explanation / Answer
void main(){
char Subject[5][20];
float cost[5] = {0.0};
for(int i=0;i<5;i++){
cout<<"Enter the subject of book number "<<i+1;
gets(Subject[i]);
cout<<" Enter cost of the book ";
cin>>cost[i];
}
for(int j=0;j<5;j++){
cout<<puts(Subject[j])<<" costs "<<cost[j];
}
int index = 0;
float value = cost[0];
int k;
for( k=0;k<5;k++){
if(cost[k]<value){
value = cost[k];
index = k;
}
}
cout<<"Cheapest Book is ";
puts(Subject[k]);
cout<<" With price "<<cost[k];
getch()
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.