Skip to content

Instantly share code, notes, and snippets.

@ericksuryadinata
Created August 29, 2018 13:45
Show Gist options
  • Save ericksuryadinata/7e1d925bd6f8b78957ccbbcb7051c2c8 to your computer and use it in GitHub Desktop.
Save ericksuryadinata/7e1d925bd6f8b78957ccbbcb7051c2c8 to your computer and use it in GitHub Desktop.
Saya gak tau kalo ini bener gaknya :D
#include <iostream>
#include <string>
#include <algorithm>
int main(){
std::string weather, location, means, actions;
int distance, time;
std::cout<<"Distance ? ";
std::cin>>distance;
std::cout<<"Time in minutes ? ";
std::cin>>time;
std::cout<<"Weather: bad/good ? ";
std::cin>>weather;
std::cout<<"Location: Downtown / Not Downtown ? ";
std::cin.ignore();
std::getline(std::cin,location);
std::cout<<std::endl;
std::cout<<distance<<std::endl;
std::cout<<time<<std::endl;
std::cout<<weather<<std::endl;
std::cout<<location<<std::endl;
if(distance > 5){
means = "drive";
}else if(distance > 1 && time < 15){
means = "drive";
}else if(distance > 1 && time > 15){
means = "walk";
}
std::transform(location.begin(), location.end(), location.begin(), ::tolower);
std::transform(weather.begin(), weather.end(), weather.begin(), ::tolower);
if(means.compare("drive") == 0 && location.compare("downtown") == 0){
actions = "take a cab";
}else if(means.compare("drive") == 0 && location.compare("downtown") != 0){
actions = "drive your car";
}else if(means.compare("walk") == 0 && weather.compare("bad") == 0){
actions = "take a coat and walk";
}else if(means.compare("walk") == 0 && weather.compare("good") == 0){
actions = "walk";
}
std::cout<<"Solutions : "<<actions;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment