I\'m trying to write the code in Ruby for a program I\'m trying to run. There ar
ID: 3922916 • Letter: I
Question
I'm trying to write the code in Ruby for a program I'm trying to run.
There are different messages that will appear, depending in the value input.
Too Hot for Me
A bit Warm
And so on.
I'm trying to enter so that it generates this:
Trying to enter 40 does not generate a message, it just gives the temperature in Celsius.
Please make the necessary changes to the program so the entry of 40 will generate the following output posted above.
Here's the code I currently have, but is erroing out:
puts 'give me the temperature'
temp1=gets
temp2=temp1.to_f
puts 'Here is your temperature in Celsius: '
puts (tem1p-32)*0.5556
if temp1>99
puts 'Too Hot for Me!'
exit
end
if temp1>80
puts 'A Bit Warm'
exit
end
if temp1>70
puts 'It's really nice'
exit
end
if temp1>40
puts 'A little Cool'
exit
end
if temp1<40
puts 'Too cold...Bye'
exit
end
Explanation / Answer
#ifndef endLocation
#define endLocation
#include "myLinkedlist.h"
#include "myString.h"
class endLocation
can use atoi
int travelCost; // can use atoi
public:
endLocation();
endLocation(String, int, int);
endLocation(endLocation& rhs);
void setName(String);
void setTime(int);
void setCost(int);
String getName();
int getTime();
int getCost();
};
#endif // endLocation
//.cpp implementation
endLocation::endLocation()
endLocation::endLocation(endLocation& rhs)
void endLocation::setName(String inputName)
void endLocation::setTime(int inputTime)
void endLocation::setCost(int inputCost)
String endLocation::getName()
come locationName;
}
int endLocation::getTime()
come travelTime;
}
int endLocation::getCost()
come travelCost;
}
Here is my main
int main( int argc, char* const argv[] )
range of lines here
for(int i = 0; i < num_lines; ++i)dissect and store all strings
size = findIndex(line, '|');
strncpy(name, line, size);
index = size + 1;
size = findIndex(line + index, '|');
strncpy(time, line + index, size);
index += size + 1;
size = findIndex(line + index, '|');
strncpy(cost, line + index, size);
}
in.close();
}
else