kes166 37 Practically a Master Poster

Figured it out. Did a google search on the junk characters and apparently it's common for some editors to add UTF-8 characters. I recreated the text file and that fixed the issue.

kes166 37 Practically a Master Poster

You're right, it needs to be declared dynamically which I missed and can be done using a pointer. This code should allow for user input to declare an array of the appropriate size.

int Floors;
cin >> Floors;
double* Room = new  double[Floors+1];

Thanks for the correction! :)

kes166 37 Practically a Master Poster

Is it repeating "Floors" times - meaning is the input being displayed as many times as you have Floors?

I'm guessing you want to display the available, occupied, etc, per floor. You are correct in your assumption that you will need arrays to do this. The problem is in the first loop when you are reading in the data to the variables, the data of the previous floor is being overwritten with the data of the last floor.

For example, let's assume floor 1 has five rooms and floor 2 has three rooms. The variable Rooms will equal 3 even though there are five rooms on floor one. When doing a cout on Rooms, it will display 3.

To get you started, you will need to define floors before you declare your array.

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
    //Variable Definitions
    int Floors;
    char choice;
    int count = 1;

   //Retrieving Floors of Hotel from User
    cout << "\nFirst, tell us how many floors does the hotel have: " << endl;
    cin >> Floors;

   //declare arrays
   double Rooms[Floors+1], occupied[Floors+1];

Floors[1] will correspond with floor 1, Floors[2] will be the second floor, etc.

Floors[0] will not be used. Notice the [Floors+1] in the declaration? That will increase the size of the array so we can disregard starting at 0. It looks like your loops are already set up for this.

kes166 37 Practically a Master Poster

Have you ever looked at a paper clip
I mean, really stop to look?

Have you ever seen how it can
Hold together the pages of a book?

Have you ever looked at a paper clip
When it shines under the light, huh?

Have you ever put it on your finger
And watched it hold on tight?

Anyone can look at a rainbow
Anyone can look at the sky
To see that those things are pretty
You don't really have to try

But, have you ever seen how a paper clip
It's so ... I don't know. So flat, huh?

Have you noticed how it keeps on bending
And say "Why, now, look at that!"

If you stopped and looked at a paper clip
For just a minute or two
You might get to love a paper clip
The way that I do

kes166 37 Practically a Master Poster

If you can get ahold of a video card that will plug into the PCIe, I'd try that. According to the specs on that motherboard, there is no on board video.

Scorps91 commented: Very useful and committed member :) +0
kes166 37 Practically a Master Poster

how would you go about splitting it?

sorry im new im really trying to learn this

I'm going to quote the code right out of the post I linked and modify it slighly.

int length=strlen(sentence);
 int check=0;    
 for(int i=length-1; i>=0; i--){
        if(sentence[i]!=' ' && i != 0){
            check++;        
        }
        else{
            for(int j=i; j<(check+i); j++)
                cout<<sentence[j+1];
                cout<<" ";
                check=0;        
        }
 }

sentence = junk#crap

You will still need to modify this code, but once you understand it, it'll be easy to see. This code cout's where you would actually need to save the values elsewhere instead of just displaying them.

kes166 37 Practically a Master Poster

An if statement.

If string[n] == '#' then split the string.

Also, take a look at this code that someone else wrote. If you can understand it, you can adapt it.

kes166 37 Practically a Master Poster

It doesn't sound like a virus. Try updating with the current driver for your graphics card. Check the website of the graphics card, or google your graphics card and you should get their website.

I would also open your computer, and check the fan on the graphics card if it has one. If the fan doesn't work on the graphics card, you'll need a new one. If the above doesn't fix your problem, you will probably need a new one also.

If the problem is with your graphics card, the longer you try to run with it, the greater the chances are that you will ruin the motherboard.

kes166 37 Practically a Master Poster
if (n == 1)
cout << "1";
else if (n == 2)
cout <<"1"<<endl<<"23";}
else if (n == 3)
cout <<"1"<<endl<<"23"<<endl<<"456";
else if (n == 4)
...

Repeat the sequence until you reach the maximum possible input for int which is I think 32,767.

After it's done, don't post your code :twisted:

Fbody commented: :twisted: Actually, for modern compilers it's about 2.1 billion :twisted: +3
kes166 37 Practically a Master Poster

line 23, set counter to 0.
line 32, your if statement is syntatically incorrect. you need ==. Also, you don't need that if statement.
Line 33, sumEvens = number + number? Think about that for a sec. If the number happens to be 2, sumEvens will be 4. The next iteration, number is 16. sumEvens will be 32. 16+2 != 32. You need to include the variable sumEvens in the addition.
line 38, you will never have a case of -1, you can erase that line.
line 37 once you get rid of 38, it will flow correctly.
line 40 your if statement is again wrong and why even have it?
line 41 same problem as line 33.

codingNewB commented: very clear and understandable instructions +0
kes166 37 Practically a Master Poster

is degree declared elsewhere? Also, you aren't assinging the static cast anywhere. x is still int, and degree is still whatever it is wherever you declared it. You would need

double value = static_cast<double>(x);
double deg = static_cast<double>(degree);
kes166 37 Practically a Master Poster

Going through how to optimize code would take months to explain. Linear code is linear code. Both statements take x amount of time. Avoid many nested loops. If you have code, it would be easier to explain where your coding might be inefficient.

Edit:

If you just want to know why, I would think it's because the first line is assigning a value to a variable where the CPU has to look up the value in *ptr where the second line, you are just assigning a value directly to the variable and no other work is needed.

kes166 37 Practically a Master Poster

i wanted to use the strcmp command, but the assignment addresses us not to do so.
is there another way to do that or do i have to go and specify something like

//would i have to do this with every possible way of debug if i dont use the strcmp command?

 else if (command == "debug" || command == 'Debug' || command == 'DEBUG')   
   {
         cout << "will allow you to execute in debug mode\n";  
    }

Do what FBody suggested, and use the toupper() or tolower(), loop through the command and make all the characters in the string upper or lower case, then you can compare command to the lowercase (or uppercase) version of the word.

int main (int argc, char *argv[]){
    string command = "DeBuG";
    int i = 0;
    while (i < command.length){
        command[i] = tolower(command[i]);
        i++;
    }
    cout << command;

The output should be debug

kes166 37 Practically a Master Poster

A few things here .... First, wrap your code in code tags. It makes it easier to read.

Secondly, what kind of error are you getting?

Thirdly, I noticed that your while loop runs until temp != Null but two lines down from that you try to reference temp->next->word. If temp is the last item in the list, you are trying to reference data on a node that doesn't exist. temp->next = null but you are trying to get temp->next->word.

finally, you aren't actually sorting nodes in the function. You are just moving string values around the variables a, b, and c. It's not doing anything.

Ancient Dragon commented: good answers :) +33
kes166 37 Practically a Master Poster

Edited because I was wrong:
You can call someFunction by s1.someFunction(s2) and have it return whichever value you want, but you will still need to make it a void function if you want both values returned. It would be easier to make a seperate function to access s1's b vaule.

Depending on what you want the function to do, return the highest, lowest, or whatever, you'd just return whichever one you wanted. If you wanted to return both, you would need to use pointers in the function and make it void.

You also need a constructor as already stated.

bmos31 commented: s1.someFunction(s2) is exactly what I was looking for..Thanks! +1
kes166 37 Practically a Master Poster

The value is returned to the location where the function call came from

total(num1,num2);

However, you didn't assign it to a variable. The return statement returns the value sum to the function call.

You can do it two ways, either set the returned value to a variable declared in the block of code where you used it, or print the value directly.

foo = total(num1,num2); //foo holds sum

or

cout << "The value is: " << total(num1, num2);

Either way should work.

JDean89 commented: Thanks alot +0