samedi 9 septembre 2023

everytime I try to run my program, it shows error-std::basic_ostream

I am trying to do this in my online book-zybook.

#include <iostream>
using namespace std;
double MphAndMinutesToMiles(double milesPerHour,double minutesTraveled){
   double hoursTraveled;
   double milesTraveled;
   hoursTraveled = minutesTraveled / 60.0;
   milesTraveled = hoursTraveled * milesPerHour;
   return cout << "Miles: " << milesTraveled << endl;
}
/* Your solution goes here  */

int main() {
   double milesPerHour;
   double minutesTraveled;

   cin >> milesPerHour;
   cin >> minutesTraveled;

Output:

main.cpp: In function ‘double MphAndMinutesToMiles(double, double)’:
main.cpp:8:46: error: cannot convert ‘std::basic_ostream<char>::__ostream_type’ {aka ‘std::basic_ostream<char>’} to ‘double’ in return
    8 |    return cout << "Miles: " << milesTraveled << endl;
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
      |                                              |
      |                                              std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}

I have tried everything, but I still don't know what the error is.

Aucun commentaire:

Enregistrer un commentaire