Created
April 29, 2023 08:52
-
-
Save arisupriatna14/daa8bbef1014f19d50718a8a0e3a4db1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link Repl untuk menjalankan kode di atas:
https://replit.com/@arisupriatna/MediumpurpleQueasyRoutes#main.cpp