#include // Physical quantities can be described by their // dimensions. // // For example, using // // M = mass, // L = length, // T = time, // // velocity has dimensions // // L T^(-1), // // acceleration has dimensions // // L T^(-2), // // and force has dimensions // // M L T^(-2). // // We can represent a dimension by giving the exponent of // each of M, L and T. For example: // // Mass Length Time // // mass 1 0 0 // length 0 1 0 // time 0 0 1 // velocity 0 1 -1 // acceleration 0 1 -2 // force 1 1 -2 // // Write a program that asks the user for the integer // exponents of mass, length and time. // // Determine whether those exponents correspond to one of // the following quantities and print its SI unit: // // Quantity Dimensions SI unit // // mass M kg // length L m // time T s // area L^2 m^2 // volume L^3 m^3 // velocity L T^(-1) m/s // acceleration L T^(-2) m/s^2 // frequency T^(-1) Hz // force M L T^(-2) N // energy M L^2 T^(-2) J // power M L^2 T^(-3) W // pressure M L^(-1) T^(-2) Pa // // If the exponents do not correspond to any quantity // listed above, print // // unknown dimension // // For example, the dimensions of force are // // M L T^(-2), // // so the user would enter // // mass exponent: 1 // length exponent: 1 // time exponent: -2 // // and the program would print // // N // // To read more about the International System of Units, // see: // // https://en.wikipedia.org/wiki/International_System_of_Units // Function declarations int main(); // Function definitions int main() { return 0; } // Hint: // // Use a cascading conditional statement. // // Each condition must check all three exponents. // // For example, force has dimensions // // M L T^(-2), // // so its exponents are // // mass = 1 // length = 1 // time = -2. // // Consequently, you could recognize force using // // (mass == 1) && (length == 1) && (time == -2) // // You will need a similar condition for each quantity // listed above. // Here is one solution: /* int main() { // Using variable names of similar lengths can sometimes // make related code easier to read. int mass{}; std::cout << "Enter the exponent of mass: "; std::cin >> mass; int leng{}; std::cout << "Enter the exponent of length: "; std::cin >> leng; int time{}; std::cout << "Enter the exponent of time: "; std::cin >> time; if ( (mass == 1) && (leng == 0) && (time == 0) ) { // Mass: M std::cout << "kg" << std::endl; } else if ( (mass == 0) && (leng == 1) && (time == 0) ) { // Length: L std::cout << "m" << std::endl; } else if ( (mass == 0) && (leng == 0) && (time == 1) ) { // Time: T std::cout << "s" << std::endl; } else if ( (mass == 0) && (leng == 2) && (time == 0) ) { // Area: L^2 std::cout << "m^2" << std::endl; } else if ( (mass == 0) && (leng == 3) && (time == 0) ) { // Volume: L^3 std::cout << "m^3" << std::endl; } else if ( (mass == 0) && (leng == 1) && (time == -1) ) { // Velocity: L T^(-1) std::cout << "m/s" << std::endl; } else if ( (mass == 0) && (leng == 1) && (time == -2) ) { // Acceleration: L T^(-2) std::cout << "m/s^2" << std::endl; } else if ( (mass == 0) && (leng == 0) && (time == -1) ) { // Frequency: T^(-1) std::cout << "Hz" << std::endl; } else if ( (mass == 1) && (leng == 1) && (time == -2) ) { // Force: M L T^(-2) std::cout << "N" << std::endl; } else if ( (mass == 1) && (leng == 2) && (time == -2) ) { // Energy: M L^2 T^(-2) std::cout << "J" << std::endl; } else if ( (mass == 1) && (leng == 2) && (time == -3) ) { // Power: M L^2 T^(-3) std::cout << "W" << std::endl; } else if ( (mass == 1) && (leng == -1) && (time == -2) ) { // Pressure: M L^(-1) T^(-2) std::cout << "Pa" << std::endl; } else { std::cout << "unknown dimension" << std::endl; } return 0; } */