#include <iostream>
#include <iomanip>
#include <string>
usingnamespace 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.
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
usingnamespace 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