-2

I am trying to price group. For example: a tutor costs 100 euro per 5 people; 6 people needs 2 tutors so it comes to 200 euro.

Basically I don't know how to go about this, this is what I tried. What I did works perfectly but let's say the user enters a bigger number and I didn't put an if statement how can I fix it? Thanks

int tutorprice;
int students;

Console.WriteLine("How many students");
students = Convert.ToInt32(Console.ReadLine());

if (students <= 1 && students <= 5) 
{
   tutorprice = 100;
}
else if (students > 5 && students <=10 ) 
{
   tutorprice = 200;
}
Rehan Shah
  • 1,505
  • 12
  • 28
Robert
  • 21
  • 1
  • 4
  • 12
    Why don't you start by ignoring programming for a moment, get a pencil and paper and write down the basic math first. Shouldn't be too difficult. After you got the math down on paper, translating it to C# shouldn't make you any problems anymore... –  Jan 05 '19 at 17:59
  • As @elgonzo said, at this point this isn't necessarily a programming problem as much as it is a mathematics problem. If you're looking for an answer as to what the formula would be for this problem, you could try directing your question to https://math.stackexchange.com/. – devNull Jan 05 '19 at 18:21
  • Yeah you guys are right I probably need to take a break problem is i'm on a deadline, this is quite a basic question but i'm not sure on how to word it. That's why I decided to ask here. – Robert Jan 05 '19 at 18:27
  • 1
    Without knowing the full formula (110/5, 200/6, ???/7, etc) there is no help to be given. – gilliduck Jan 05 '19 at 18:33
  • yeah thats why basically 100 euro per group of 5 , if the group is 11 , 3 tutors are needed so 300 euro – Robert Jan 05 '19 at 18:59
  • Why 3 tutors for a group of 11? What about a group of 14, or a group of 21? And don't forget a group of 16... You surely can put that logic in some formula/equation, no? I am sorry to say, but there is no programming question here. If you can't express/explain this formula/equation, then there is no can do. Not having formulated the formula/equation is a showstopper. (It would be like you asking us how to drive a train without having any railroad to drive on, and us telling you to not worry about how to drive a train unless you have built the railroad first) –  Jan 05 '19 at 21:15
  • Thanks for replying elgonzo but I don't think you are getting the question, or I explained it wrongly. Basically 1 tutor is for 5 students, but if there are 6 students another tutor is needed, so I need to print 2 tutors needed, if there are 7 students still 2 tutors because 1 tutor every group of 5. – Robert Jan 05 '19 at 21:58
  • 1
    Isn't it a case of dividing by 5 and rounding up? – customcommander Jan 05 '19 at 23:32

1 Answers1

0

You have 2 problems here. First of all you need to learn basic implementation. For that you can search help other places. To implement the best calculating function you should look at this topic : Math Round to always upper integer

M.Hazara
  • 137
  • 9
  • Found exactly what I needed, thanks alot for the answer! Guess I didn't know how to explain it properly. – Robert Jan 05 '19 at 22:14