Program almost done, just one problemo

Jan 31, 2012 at 5:12am
I have undefined areas in terms of where my room and floor # are. Here's my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;
void main ()

{
	int MAXRANGE= 999;
	unsigned hotel;
	cout<<"enter a three or four digit number \n";
	cin>> hotel;
	int floor=roomnumber/100;
	int roomnumber=roomnumber%100;
	cout<<"Your floor is"<<floor<<"Press enter to get room number"<<endl;
	cin>>floor;
	cout<<"Your room number is"<<roomnumber<<endl;

	



	
}


How would I define the two to let the user enter any given number, yet let the math work. I am a complete newbie to programming, so please be gentle! The goal of my program is to allow the user to enter a three of four digit number. The numbers would then essentially split and allow the user to see their room number/floor number. For instance 123 would make '1' the floor number and '23' the room number.
Jan 31, 2012 at 5:31am
Made additional changes..this should be simple, right??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;
void main ()

{
	int MAXRANGE= 9999;
	unsigned hotel;
	cout<<"enter a three or four digit number \n";
	cin>> hotel;
	int floor ('1');
	int roomnumber ('1');
	floor=roomnumber/100;
	roomnumber=roomnumber%100;
	cout<<"Your floor is"<<floor<<endl;
	cin>>floor;
	cout<<"Press enter to get room number \n";
	cin>>roomnumber;
	cout<<"Your room number is"<<roomnumber<<endl;


It's just spurting out random numbers. There are no errors though!
The output should be something like:
Enter a three or four digit number
4555
Your floor is 4
Press enter to get room number (the enter function isnt working either)
Your room number is 555
Jan 31, 2012 at 5:40am
Fixed it, but it only works with four digit numbers. Any clue to why?
Topic archived. No new replies allowed.