how to create programme code for the condition below?


1)user must key in total amount of sales per day. example, $234

2)programme should calculate salary
salary=sale x 9%+200

input of sales should loop 5 times (repeated 5 days).

salary then should be ranged into following

200-399
400-699
700-999
1000-1499
more than 1500

programme dont have to show the amount of salary as output, instead should give the range and no. of sales

output is something like below......

200-399.........2 sales
400-699...........0 sales
700-999..........1 sale
1000-1499...........2 sales
more than 1500..........0sales


programme must use call function.
# include <stdio.h>
# include <conio.h>

i m using borland c++ 5.02
Well, since you need to remember five days worth of data, that suggests using an array (I assume you are using C, not C++).

However, you are asked to track salaries, not daily sales, so your array should represent the number of sales for each salary range.

In main, just loop five times. Each time, ask for the daily sales, convert it to a salary, determine which salary range it falls in, and add 1 to the corresponding element of your array.

Then you can loop again and print out all your data.

Hope this helps.
Last edited on
Heh lucky for you i was bored enough to do your homework (sure sounds like homework :P):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// salary scale 

#include <iostream>




using namespace std; 



int main()
{
	cout << "Enter sales for this week: " << endl << endl;
	int nSalesArray[5];
	int nSalaryArray[5];
	int nInp;
	int nScale1 = 0 ; //200/399
	int nScale2 = 0; //400/699
	int nScale3 = 0; //700/999
	int nScale4 = 0; //1000/1499
	int nScale5 = 0; //<1500

	
	for(int n = 0; n < 5; n++)
	{
		cout << "Day " << n+1 << ": $";
		cin >> nInp;
		nSalesArray[n] = nInp;
		nSalaryArray[n] = ( nSalesArray[n] * 0.09 ) + 200;
	
		if(nSalaryArray[n] <= 399)
			nScale1 += 1;
		else if(nSalaryArray[n] >= 400 && nSalaryArray[n] <=699)
			nScale2 +=1;
		else if(nSalaryArray[n] >= 700 && nSalaryArray[n] <=999)
			nScale3 +=1;
		else if(nSalaryArray[n] >= 1000 && nSalaryArray[n] <=1499)
			nScale4 +=1;
		else
			nScale5 +=1;
	}
	
	cout << endl;
	cout << "$200-$399................ " << nScale1 << " sales." << endl;
	cout << "$400-$699................ " << nScale2 << " sales." << endl;
	cout << "$700-$999................ " << nScale3 << " sales." << endl;
	cout << "$1000-$1499.............. " << nScale4 << " sales." << endl;
	cout << "$1500 +.................. " << nScale5 << " sales." << endl << endl;
	
}


Disclaimer: If this really is homework i should tell you that i just started programming so this code might be to messy, not efficient enough to satisfy your teacher.
Ebbo, please don't do other people's homework for them. It teaches them nothing and professors really can spot plagiarism from a mile away. (Though, surprisingly often they just don't care that much in beginning classes...) If I were the teacher I'd fail my student for the semester.
Last edited on
I know i shouldnt have but as i said before im just starting to learn c++ and i thought it was actually a fun exercise to do.
Last edited on
hey duoas!! stop assuming things. i m a biotechnology student n i'm just interested in programming. like ebbo.. anyway i got no teacher , coz i m learning myself..using internet and books!!!! by the way, whats giving you pain in the ass.? r u working out there??? thank god u are not a lecturer.. i dont think you can be one.... hahahaha..

ps. if i were your student, you would have been murdered by me long ago.

DUOAS IS A DEMOTIVATOR.

hey ebbo. you rock man!! thx..
@exypnos

I don't think that your language here is acceptable.

Duoas has a very valid point. He did not forbit ebbo to post "homeworks" but merely stated the obvious: If you do not do it yourself you do not learn a thing.

And I am certainly with duoas that I would let everybody who copy and pastes his papers have an F for said paper. That's, by the way, stated in every exemination-regulations of every university I know.

So don't be upset about such statements because thez are valid and necessary and most importantly
YOU SHOULD NOT THREATEN ANYBODY!

int main
@exypnos.
Nobody cares if your a student studying programming or not. You had an "assignment" question to do (be it personal or professional) and you made no attempt yourself to complete it. That's just lazy, and unfortunately every day multiple people just like you post up requirements expecting someone else to do the work for them.

Duoas was merely pointing out that by doing the work for you Ebbo was setting a bad example, as more and more people will expect work to be done for them. I don't think Duoas would be a bad lecturer, I think you'd just fail.

And personal insults, especially on the life of someone are illegal in most countries. So best watch what you say/type.
what is it with you zaita???

pls guys... stop posting !!!!

i dont remember asking anyone to ADVISE me!!!!!!!!!
closed account (z05DSL3A)
By the very nature of an open forum, you will get advice that you may not have asked for. You may choose to ignore it, but it is worth remembering that the advice is coming from the people that you have asked for help. They are giving their time (freely) to help you and others. It may seem like they are not helping, but the intention is there.

I do hope that you have learnt from the code that ebbo posted for you, but it is still true that you will learn ‘better’ if you do the work yourself.

Good luck in your studies.
Topic archived. No new replies allowed.