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

1.(80marks) An organization that your little cousin belongs to is selling low-fa

ID: 3606239 • Letter: 1

Question

1.(80marks) An organization that your little cousin belongs to is selling low-fat cookie If your cousin's class sells more cookies than any other class, the teacher has promised take the whole class on a picnic. Of course, your cousin volunteered you to keep track all the sales and determine the winner. Each class has an identification number. Eaclh sales slip has the class identification number and the number of boxes sold. Input (Note: if you use keyboard for the input, it is ok for this assignment) Here is a sample of the data. (The classes are numbered from 1 through 10.) Id. Number Boxes Sold 23 13 10 16 Output The following information written on file "boxes.out", all properly labeled. The total number of boxes sold by each class. The identification number of the winning class. If there is a tie, list all winners Data Structures: using class UnsortedType defined in the textbook (chapter 3). The interface is provided as follows. You can use either array or LinkedList as the fundamental data structure. Deliverables Part I CRC card to - Your design (objected-oriented design). (use diagrams, pseudo-code, show your logical level design) Part II - A listing of your program (implementation of the program in C++) -A listing of your test plan as input to the program - A listing of the output file Interface of Unsorted Type class: bool IsFullO const; / Function: Determines whether list is full. / Pre: List has been initialized.

Explanation / Answer

The C++ program for the problem:

class Cookie
{
public:
int a[10];
int id;
int boxsold;

public:
Cookie()
{
id=0;
boxsold=0;
}
};
#include <iostream>
#include <fstream>
#include <iomanip>


using namespace std;

int main()
{
Cookie sale;
int id,box,ch;
std::ofstream outputfile ;
for(int i=0;i<10;i++)
{

sale.a[i]=0;

}

cout<<"nPress1 if you want to enter data";
cin>>ch;
while(ch==1){
cout<<"nEnter the identification number for each box that is sold";
cin>>id;
cout<<"nEnter the number of boxes sold";
cin>>box;

for(int i=0;i<10;i++){
if(i==id){
sale.a[i]+=box;
}

}
cout<<"nPress1 for enter data";
cin>>ch;

}
int max=sale.a[0];
int maxid=0;
for(int i=1;i<10;i++){
if(sale.a[i]>max){
max=sale.a[i];
maxid=i;
}
if(sale.a[i]==0){
sale.a[i]=1;
}

}
cout<<"nThe array is";
for(int i=0;i<10;i++){

cout<<"n";
cout<<sale.a[i];
}

outputfile.open ("boxes.txt", std::ofstream::out | std::ofstream::app);
outputfile <<"nThe class that sold maximum no. of boxes is ";
outputfile <<maxid;
outputfile <<"n Maximum no. of boxes sold are ";
outputfile <<max;
outputfile.close();
return 0;
}