Saturday, May 25, 2024

Temperature Converter Using Object-Oriented Programming in C++

Temperature Converter in C++ Using Object-Oriented Programming

 




#include <iostream>

#include <iomanip>


class TemperatureConverter {

public:

    // Constructor

    TemperatureConverter() {}


    // Convert Celsius to Fahrenheit

    double celsiusToFahrenheit(double celsius) {

        return (celsius * 9.0 / 5.0) + 32;

    }


    // Convert Fahrenheit to Celsius

    double fahrenheitToCelsius(double fahrenheit) {

        return (fahrenheit - 32) * 5.0 / 9.0;

    }

};


int main() {

    TemperatureConverter converter;

    char choice;


    do {

        std::cout << "\n\n\tTemperature Converter Main Menu\n" << std::endl;

        std::cout << "\t[1] Celsius to Fahrenheit" << std::endl;

        std::cout << "\t[2] Fahrenheit to Celsius" << std::endl;

        std::cout << "\t[3] Quit Program" << std::endl;

        std::cout << "\n\tEnter your choice: ";

        std::cin >> choice;


        if (choice == '1') {

            double celsius;

            std::cout << "\tEnter temperature in Celsius: ";

            std::cin >> celsius;

            double fahrenheit = converter.celsiusToFahrenheit(celsius);

            std::cout << "\tTemperature in Fahrenheit: " <<std::fixed <<std::setprecision(2)<< fahrenheit << std::endl;

        } else if (choice == '2') {

            double fahrenheit;

            std::cout << "\tEnter temperature in Fahrenheit: ";

            std::cin >> fahrenheit;

            double celsius = converter.fahrenheitToCelsius(fahrenheit);

            std::cout << "\tTemperature in Celsius: " <<std::fixed <<std::setprecision(2)<<  celsius << std::endl;

        } else if (choice != '3') {

            std::cout << "\n\tInvalid choice. Please try again." << std::endl;

        }


    } while (choice != '3');

    std::cout << "\n\tEnd of Program. Thank you for using this program." << std::endl;

    return 0;

}


My 2nd Citation in Google Scholar

Monday, May 20, 2024

What is Mechatronics?

What is Mechatronics?

 


What is Mechatronics?


Mechatronics is a multidisciplinary field that refers to the skill sets needed in the contemporary, advanced automated manufacturing industry. At the intersection of mechanics, electronics, and computing, mechatronics specialists create simpler, smarter systems.

Monday, May 13, 2024

What is Business Intelligence?

What is Robotics?

What is Robotics?

 What is Robotics?


In simple terms, robotics combines science, engineering, and technology to design, construct, operate, and use machines programmed to replicate, substitute, or assist humans in completing tasks of varying complexity. These machines are known as robots.