Use C++ language. Comment in the codes would great. 2. (80) An organization that
ID: 3728505 • Letter: U
Question
Use C++ language.
Comment in the codes would great.
Explanation / Answer
The below code represents C++ program:
CODE:
Class Cookie
{
Public:
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;
}
Count<<”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;<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];
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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.