Use c++.
Define a function ConvertLength() that takes one integer parameter as totalMeters and two integer parameters passed by reference as kilometers and meters. If totalMeters is negative, the function returns false without updating the parameters. Otherwise, the function converts total Meters to kilometers and meters, and then returns true. Ex: If the input is 5100, then the output is: 5 kilometers and 100 meters Notes: ● • totalMeters/ 1000 computes the number of kilometers, and totalMeters % 1000 computes the remaining meters. A non-negative number is greater than or equal to 0. ● 1 #include <iostream> 2 using namespace std; 3 4 /* Your code goes here */ 5 6 int main() { 7 8 9 10 11 12 13 14 510 15 ---- 16 17 18 int usrKilometers; int usrMeters; int totalMeters; bool valid; usrKilometers = 0; usrMeters = 0; cin >> totalMeters; valid = ConvertLength(totalMeters, usrKilometers, usrMeters);
Use c++.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am