Answer to Question #291264 in C++ for Nomcebo

Question #291264


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.



1
Expert's answer
2022-01-27T12:55:14-0500
#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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog