this is actually really easy and just a few lines. Because it is so simple (its what, 4 lines + I/O and variable defines?), and likely your first program, I did it for you. I did not spend a ton of time on testing it or dong nice input and output prompts etc, but I think it is close, you can polish up the I/O and all.
edit: oops, fixed, I did 3+days not 2+ days initially.
edit2: removed silly multiply by 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
string getanswer(int d, int ty)
{
string ans;
static const vector<int> rooms{3000,5000,6000,10000};
static const vector<double> rt{1.0,0.92,0.9,0.88};
double t{0.0},pa{0.0};
t = d*rooms[ty];
pa = t* rt[ ((d>1)&&t>4000) +((d>1)&&t>8000) + ((d>1)&&t>12000) ];
ans += to_string(t)+" "+to_string(pa); //finish this up for the output
return ans;
}
int main()
{
int duration{0};
int roomtype{0};
cout << "how long?\n"; //this can be better.
cin >> duration;
cout <<"type?\n";
cin >> roomtype;
cout << getanswer(duration,roomtype);
}
|
them are some expensive rooms. You in backwards format number country (where comma and decimal are reversed? I used american)??
I only do the raw beginner stuff for people. Next time, you must try to do it yourself or I will not help, as the others have said. All I ask is that if you turn this in, I want to know what the professor had to say about it, as I always like an expert's opinion of my code attempts. Also be sure you understand it; you have to be able to do the first assignments yourself or you will fail the rest quickly as it builds. And ok... the funny wore off, I was messing with you a bit. It works, and it may even be educational to you, but its on par with using calculus to find the area of a rectangle. Try to do it using what you know, post it, and we will help. Cheating won't work for this material, for very long. You may survive the first class but you will very soon be discovered as unable to do even simple things, and whatever consequences will follow.