Ten students had worked in a clothing store during the holidays. At the end of
the holiday, they receive a wage according to the number of items that they
sold. The rate of pay is R6.50 per item. Enter the student name and the
number of items that the student sold during the holidays and display the
student name and the amount earned by every student. Also calculate and
display the student name of the student who sold the most items.
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
using namespace std;
#define NO_OF_STUDENTS 3
/*
Ten students had worked in a clothing store during the holidays. At the end of
the holiday, they receive a wage according to the number of items that they
sold. The rate of pay is R6.50 per item. Enter the student name and the
number of items that the student sold during the holidays and display the
student name and the amount earned by every student. Also calculate and
display the student name of the student who sold the most items.
*/
int main()
{
int n=0,UnitsSold[NO_OF_STUDENTS],Max,ind=0;
string Name[NO_OF_STUDENTS];
float UnitPrice=6.50;
for(n=0;n<NO_OF_STUDENTS;n++)
{
cout<<"\n\tEnter Student #"<<n+1<<" Namne: "; cin>>Name[n];
cout<<"\n\tEnter Units Sold: "; cin>>UnitsSold[n];
}
Max = UnitsSold[0];
for(n=0;n<NO_OF_STUDENTS;n++)
{
cout<<"\n\tName: "<<Name[n]<<"\tUnits Sold = "<<UnitsSold[n]<<"\tSell Amount = "<<UnitPrice*UnitsSold[n];
if(Max<=UnitsSold[n]) {Max = UnitsSold[n]; ind=n;}
}
cout<<"\n\n\tMax. Sale by student: "<<Name[ind]<<"\tUnits Sold = "<<UnitsSold[ind]<<"\tTotal sale amount = "<<UnitsSold[ind]*UnitPrice;
return(0);
}
Comments
Leave a comment