Skip to content

Instantly share code, notes, and snippets.

@arisupriatna14
Created April 29, 2023 08:52
Show Gist options
  • Save arisupriatna14/daa8bbef1014f19d50718a8a0e3a4db1 to your computer and use it in GitHub Desktop.
Save arisupriatna14/daa8bbef1014f19d50718a8a0e3a4db1 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class FahrenheitToCelcius {
public:
double convert(double f) {
return (f - 32.0) * 5 / 9;
}
float convert(float f) {
return (f - 32.0) * 5 / 9;
}
int convert(int f) {
return (f - 32) * 5 / 9;
}
};
int main() {
FahrenheitToCelcius converter;
// menggunakan tipe data double
double f1 = 100.0;
double c1 = converter.convert(f1);
cout << "Pemanggilan dengan tipe data double" << endl;
cout << "Proses dengan tipe data double" << endl;
cout << f1 << " sama dengan " << c1 << endl;
// menggunakan tipe data float
float f2 = 100.0f;
float c2 = converter.convert(f2);
cout << "Pemanggilan dengan tipe data float" << endl;
cout << "Proses dengan tipe data float" << endl;
cout << f2 << " sama dengan " << c2 << endl;
// menggunakan tipe data integer
int f3 = 100;
int c3 = converter.convert(f3);
cout << "Pemanggilan dengan tipe data integer" << endl;
cout << "Proses dengan tipe data integer" << endl;
cout << f3 << " sama dengan " << c3 << endl;
return 0;
}
@arisupriatna14
Copy link
Author

Link Repl untuk menjalankan kode di atas:
https://replit.com/@arisupriatna/MediumpurpleQueasyRoutes#main.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment