Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "This is a programme about converts in length units." << endl;
- cout << "The units that are used in this programme are: " << endl << endl;
- cout << "Meters (and dm and cm), yards, feet and inches" << endl;
- cout << "There are the following choices: " << endl << endl;
- cout << "1. Meter ---> Yard" << endl;
- cout << "2. Meter ---> Feet" << endl;
- cout << "3. Meter ---> Inch" << endl;
- cout << "4. Yard ---> Meter" << endl;
- cout << "5. Yard ---> Feet" << endl;
- cout << "6. Yard ---> Inch" << endl;
- cout << "7. Feet ---> Yard" << endl;
- cout << "8. Feet ---> Feet" << endl;
- cout << "9. Feet ---> Inch" << endl;
- cout << "10. Inch ---> Meter" << endl;
- cout << "11. Inch ---> Feet" << endl;
- cout << "12. Inch ---> Inch" << endl << endl;
- // Ask from the user which convert to do
- cout << "Press a number from 1 to 12 to choose which convert do you want me to do." << endl;
- int choice;
- cin >> choice;
- double data;
- // The convert is:
- // 1 foot = 0.305 meters
- // 1 foot = 12 inches , so inch = 2.54 cm
- // 1 yard = 3 feet = 36 inches, so yard = 0.915 meters
- switch(choice){
- case 1:
- cout << "How many meters? " << endl << endl;
- cin >> data;
- cout << data << " meters = " << data * 10 << " dm = " << data * 100 << " cm = ";
- cout << 1000 * data << " mm = " << 1 / 0.915 * data << " yards " << endl << endl;
- case 2:
- cout << "How many meters? " << endl << endl;
- cin >> data;
- cout << data << " meters = " << data * 10 << " dm = " << data * 100 << " cm = ";
- cout << 1000 * data << " mm = " << 1 / 0.305 * data << " yards " << endl << endl;
- case 3:
- cout << "How many meters? " << endl << endl;
- cin >> data;
- cout << data << " meters = " << data * 10 << " dm = " << data * 100 << " cm = ";
- cout << 1000 * data << " mm = " << 1 / (0.305 / 12) * data << " yards " << endl << endl;
- case 4:
- cout << "How many yards? " << endl << endl;
- cin >> data;
- cout << data << " yards = " << 0.915 * data << " meters = " << 9.15 * data << " dm = ";
- cout << 91.5 * data << " cm = " << 915 * data << " mm" << endl << endl;
- case 5:
- cout << "How many yards? " << endl << endl;
- cin >> data;
- cout << data << " yards = " << 3 * data << " feet" << endl << endl;
- case 6:
- cout << "How many yards? " << endl << endl;
- cin >> data;
- cout << data << " yards = " << 36 * data << " inches" << endl << endl;
- default:;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement