Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <cstdlib>
- #include <conio.h>
- using namespace std;
- /* program do przeliczania konwersji temp.
- na podstawie Molivos 2017
- Wzory:
- Tc = (5/9) * (Tf - 32)
- Tf = 32 + (9/5) * Tc
- Tk = Tc + 273,15 */
- int main()
- {
- float cel = 0, k = 0, f = 0, lower, upper;
- f = 32 + (9/5) * cel;
- k = cel + 273.15;
- char option, choose;
- int step;
- // Menu
- for (;;)
- {
- cout << endl;
- cout << "Main Menu" << endl;
- cout << "-----------------" << endl;
- cout << "1. Calculator" << endl;
- cout << "2. Conversion Table" << endl;
- cout << "3. Exit" << endl << endl;
- cout << "Wybierz opcje: " << endl;
- option = getch();
- switch (option)
- {
- case '1':
- for (;;)
- {
- cout << "Choose unit " << endl;
- cout << "1. Celsius " << endl;
- cout << "2. Kelvin " << endl;
- cout << "3. Farenheit " << endl;
- cout << "4. Exit " << endl;
- choose = getch();
- switch (choose)
- {
- case '1':
- cout << "Imput Celcius: ";
- cin >> cel;
- cout << "Celcius: " << cel;
- cout.width(5);
- k = cel + 273.15;
- cout << "Kelvin: " << k;
- cout.width(5);
- f = 32 + (9/5) * cel;
- cout << "Farenheit: " << f << endl;
- break;
- case '2':
- cout << "Imput Kelvin: ";
- cin >> k;
- cout << "Kelvin: " << k;
- cout.width(5);
- cel = k -273.15;
- cout << "Celcius: " << cel;
- cout.width(5);
- f = 32 + (9/5) * cel;
- cout << "Farenheit: " << f << endl;
- break;
- case '3':
- cout << "Imput Farenheit: ";
- cin >> f;
- cout << "Farenheit: " << f;
- cout.width(5);
- cel = (f - 32) * 5/9;
- cout << "Celcius: " << cel;
- cout.width(5);
- k = cel + 273.15;
- cout << "Kelvin: " << k << endl;
- break;
- case '4':
- exit(0);
- break;
- default:
- cout << "Ni ma takiej opcji ziomek " << endl;
- }
- }
- case '2':
- //wejscie
- cout << "Dolna granica: ";
- cin >> lower;
- cout << "Gorna granica: ";
- cin >> upper;
- cout << "Krok: ";
- cin >> step;
- // nag³owek
- cout << "==============================\n";
- cout.width(10);
- cout << "Celcius";
- cout.width(10);
- cout << "Kelvin";
- cout.width(10);
- cout << "Farenheit";
- cout << endl << endl;
- for (cel = lower; cel <= upper; cel += step)
- {
- cout.width(10);
- cout << cel;
- cout.width(10);
- k = cel + 273.15;
- cout << k;
- cout.width(10);
- f = 32 + (9/5) * cel;
- cout << f << endl;
- }
- break;
- case '3':
- exit(0);
- break;
- default:
- cout << "Nie ma takiej opcji" << endl;
- }
- getchar();getchar();
- system("cls");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement