to the rest of the problems posten on this forum, my own seem completely inferior.
i'm stuck.
lol, i haven't much (any) C++ experience (i started my first program about 15 hours ago)
anyway, i hope u brains can help me with this as C++ seems to be a pretty cool thing to learn, but i'm baffled.
Code:
#include <iostream.h>
using namespace std;
//const float standard_charge = 2.00; // standard charge,
// per person, per hour
// Paintball assignment. A program to produce quotes
// for customers of a paintball company
void main()
{
int group_size; // size of the group
int duration; // length of times in hours
float charge; // charge for the booked session
int paintballs = 20; //each player gets 20 free per hour
float perioda = 2.60;
float periodb = 2.30;
float periodc = 2.10;
float periodd = 2.00;
int ballsa = 0;
int ballsb = 50;
int ballsc = 100;
int ballsd = 160;
int ballse = 250;
char gear;
cout<< "Enter group size (30 being the max): ";
cin>> group_size;
cout<< endl;
cin.ignore();
cout<< "Thankyou. How long do you want to play (time in whole hours)?: ";
cin>> duration;
if (duration <= 2) {
charge = perioda * (group_size * duration);
}
else if (duration >2<=5) {
charge = periodb * (group_size * duration);
}
if (duration >5<=7) {
charge = periodc * (group_size * duration);
}
else if (duration >7<=10) { //seems to * by 2.10 as opposed to 2.00
charge = periodd * (group_size * duration);
}
cout<< endl;
cin.ignore();
cout<< "The session you have specified will cost: £" << charge;
cout<< endl;
cin.ignore();
cout<< "You will receive "<< paintballs <<" free paintballs for your game.";
if (group_size <= 10) { //users only ever get 20 free paintballs
paintballs = ((group_size * duration) * paintballs) + ballsa;
}
else if (group_size >10<=15) {
paintballs = (paintballs * (group_size * duration)) + ballsb;
}
if (group_size >15<=20) {
paintballs = (paintballs * (group_size * duration)) + ballsc;
}
else if (group_size >20<=25) {
paintballs = (paintballs * (group_size * duration)) + ballsd;
}
if (group_size >25<=30) {
paintballs = (paintballs * (group_size * duration)) + ballse;
}
cout<< endl;
cin.ignore();
gear = 0;
do {
cout<< "Do you need to hire equipment at a charge of £5 per group? (Y/N): ";
cin>> gear;
} while (gear != 0 || 1);
if (gear = 0) {
cout<< "Thankyou. You have chosen not to hire any equipment.";
}
else if (gear = 1) {
cout<< "Thankyou. You have chosen to hire equipment. This session will cost: "
<<charge +5;
}
the whole 'do while' loop thing at the bottom?? i just don't get it. i want my program to ask the user whether or not they need to hire equipment and based on their answer Y or N the program then adds £5 to the final cost.
also ... another thing that baffled me is the free paintballs. each paintballer gets 20 free paintballs per hour. i then wanted to add a group booking bonus wereby larger groups get an extra 50 or 100 etc. balls. but my code seems to spill out 20 free paintballs every time.
aaaand i'm also having trouble working out what is wrong (although i realise that very little of my code is actually any good) with my duration. the first three groups 0-2, 3-5, 5-7 work fine i think, but the 8-10 doesn't.
sorry if this is all a bit trivial. i'm sure u lot get annoyed with dunce questions.