-
C++연습)How to make Unit converter in C++[kilo->mile+function+switch코딩Coding/C++_연습 2021. 12. 3. 21:43728x90
#include <iostream> using namespace std; double input, output; void kmToOthers() { system("clear"); cout << "\n\n\n\n\n\n\n\n\n\n\n\n Select a desired option: "; cout << "\n\t\t\t\t1. Km --> Miles : "; cout << "\n\t\t\t\t2. Km --> Feet : "; cout << "\n\t\t\t\t3. Km --> Inches : "; int opt; cin >> opt; switch (opt) { case 1: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Kilometers: "; input = opt; cin >> input; output = input * 0.62137; cout << "\n\n\t\t\t\t" << input << " km = " << output << " miles "; break; case 2: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Kilometers: "; input = opt; cin >> input; output = input * 3280.84; cout << "\n\n\t\t\t\t" << input << " km = " << output << " Feet "; break; case 3: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Kilometers: "; input = opt; cin >> input; output = input * 39370; cout << "\n\n\t\t\t\t" << input << " km = " << output << " Inches "; break; } } void milesToOthers() { system("clear"); cout << "\n\n\n\n\n\n\n\n\n\n\n\n Select a desired option: "; cout << "\n\t\t\t\t1. Miles --> Km : "; cout << "\n\t\t\t\t2. Miles --> Feet : "; cout << "\n\t\t\t\t3. Miles --> Inches : "; int opt; cin >> opt; switch (opt) { case 1: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Miles: "; input = opt; cin >> input; output = input * 1.6093; cout << "\n\n\t\t\t\t" << input << " Miles = " << output << " Km "; break; case 2: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Miles: "; input = opt; cin >> input; output = input * 5280; cout << "\n\n\t\t\t\t" << input << " Miles = " << output << " Feet "; break; case 3: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Miles: "; input = opt; cin >> input; output = input * 63360; cout << "\n\n\t\t\t\t" << input << " Miles = " << output << " Inches "; break; } } void feetToOthers() { system("clear"); cout << "\n\n\n\n\n\n\n\n\n\n\n\n Select a desired option: "; cout << "\n\t\t\t\t1. Feet --> Km : "; cout << "\n\t\t\t\t2. Feet --> Miles : "; cout << "\n\t\t\t\t3. Feet --> Inches : "; int opt; cin >> opt; switch (opt) { case 1: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Feet: "; input = opt; cin >> input; output = input * 0.000304; cout << "\n\n\t\t\t\t" << input << " Feet = " << output << " Km "; break; case 2: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Feet: "; input = opt; cin >> input; output = input * 0.000189; cout << "\n\n\t\t\t\t" << input << " Feet = " << output << " Miles "; break; case 3: system("clear"); cout << "\n\n\n\n\n\n\n\t\t\t\t Enter Value in Feet: "; input = opt; cin >> input; output = input * 12; cout << "\n\n\t\t\t\t" << input << " Feet = " << output << " Inches "; break; } } int main() { start: cout << "\n\n\n\n\t\t\t Your Value is is :"; cout << "\n\t\t\t\t1.Km"; cout << "\n\t\t\t\t2.Miles"; cout << "\n\t\t\t\t3.Feet"; int sele; cin >> sele; switch (sele) { case 1: kmToOthers(); break; case 2: milesToOthers(); break; case 3: feetToOthers(); break; } cout << "\n\n\t\t\t\tPress 'E' to Exit!"; char exit; cin >> exit; if (exit == 'E' || 'e') { system("clear"); goto start; } system("pause"); return 0; }
출처 :
https://www.youtube.com/watch?v=QOR_zASF5s8
반응형'코딩Coding > C++_연습' 카테고리의 다른 글
C++연습)Vector of vectors(C++ Programming Tutorial-Engineer4Free (0) 2021.12.04 C++연습] Tutorial 19 - Vectors as Parameters (0) 2021.12.04 C ++연습] 튜토리얼 18-벡터와 벡터 함수-programminghelporg (0) 2021.12.04 C++연습]Vector_push back & pop back (0) 2021.12.04 C++연습] Unit Converter (0) 2021.12.03 C++연습] Programming Challenge 77개 도전 gogo~ (0) 2021.12.03 C++연습] C++ Finding Smallest & Largest Integers(C++ While Loop) (0) 2021.12.03 C++연습]두 int를 읽어서 출력하는 while 루프로 이뤄진 프로그램 작성 (0) 2021.12.02