+ 2
Need some help on my code.
Am trying to make a lil program that is about if a worker sells 100 pencils, he's got a commission of 5%. But if he's not selling 100 pencils or only sells 99 pencils then he's got any commission. Where am I wrong at ? please correct me! Thanks in advance! #include <iostream> using namespace std; int main(){ int pencil; cout<<"Write pencils"; cin>>pencil; if(0.5*100); { cout <<"Commission earned"<<endl; } { else cout<<"0 commission"<<endl; } }
15 Answers
+ 13
You are welcome..😀
All of us are learners and with practice we get more experiance and the same for you.
Asking is the key of learning, so don't hesitate to ask.
With progrramming you must be specific in order to get the right decision.
Wish you the best..😉
+ 12
it is working fine..
try this
https://code.sololearn.com/cPRan55WnfKi/?ref=app
+ 11
you does not mention that in your question.
in order to calculate the commisson you must specify the price of pencil not only the quantity.
Please correct your question and make it clear in order to get the correct answer.
+ 11
100 pencil is the quantity but where is the price to calculate the 5% commission from the total price of quantity.
ex:
if the price of pencel is: 0.5$ and he sell 120
then he get 5% as commission from the total price.
total price = total quantity * price per unit
= 120 * 0.5$ = 60$
commission = 5% = (5 * 60$)/100 = 3$.
in this case you can calculate commission.
check the below updated code:
https://code.sololearn.com/cPRan55WnfKi/?ref=app
+ 10
when you run your program this message appear to insert the value you want.
if you insert 100 then it will asign the variable 'pencil' a value 100(that mean pencil = 100).
the output will be:
Commission earned
if you insert 50 then the output will be
0 commission
try it and if you have any question don't worry to ask.
+ 9
you can add '\n' or 'endl' to print each sentence on a separete line.
also you can print the value you inserted
#include <iostream>
using namespace std;
int main()
{
int pencil;
cout<<"Write pencils = ";
cin>>pencil;
// here you can add the value of pencil
//and make a new line with 'endl'
cout << pencil << endl;
if( pencil >= 100){
cout << "Commission earned" << endl;
}
else{
cout <<"0 commission" << endl;
}
}
+ 8
hi @CrazyRoll
you must check the inserted value (pencil)
if( pencil >= 100){
cout << "Commission earned" << endl;
}else{
cout <<"0 commission" << endl;
}
+ 1
do u mind to try my code and see what happens ? I did what u told me and still have problems I guess
#include <iostream>
using namespace std;
int main()
{
int pencil;
cout<<"Write pencils";
cin>>pencil;
if( pencil >= 100){
cout << "Commission earned" << endl;
}
else{
cout <<"0 commission" << endl;
}
}
+ 1
tho I don't know what it means when every time I run it appears on the screen that says that I have to custom input or use new lines to separate multiple inputs
+ 1
well, I inserted 100 just appeared Write pencils Commission
and when I inserted 5 it appeared
Write pencils0Commission
+ 1
Thank u so much. it's working. sorry for not telling u the price tho. It's because my professor didn't tell me if it has a price, he just said exactly what I post here.
0
well, the operation is not working tho
0
well, the operation is not working tho
0
Dude, when I insert 100, it suppose to show 5 , isn't it ?
0
I did. If he sells 100 pencils then he earns 5%. or if he doesn't sell 100 pencils he doesn't earn anything.