I'm working on this code which "Tells your future"
and despite my best efforts I cannot seem to fix this:
6_2.cpp: In function âvoid tellFortune(double, double)â:
6_2.cpp:19:35: error: invalid operands of types âdoubleâ and âintâ to binary âoperator%â
double numYears = abs(numYears) % 5;
^
6_2.cpp:20:41: error: invalid operands of types âdoubleâ and âintâ to binary âoperator%â
double numChildren = abs(numChildren) % 6;
Code:
| 2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 |
#include <iostream>
#include <cmath>
using namespace std;
void tellFortune(double, double);
int main()
{
double numYears, numChildren;
cout << "This program can tell your future. \n";
cout << "Enter two integers separated by a space: ";
cin >> numYears >> numChildren;
tellFortune(numYears, numChildren);
return 0;
}
void tellFortune(double, double)
{
double numYears = abs(numYears) % 5;
double numChildren = abs(numChildren) % 6;
cout << "\nYou will be married in " << numYears << " years " << "and will have " << numChildren << " children.\n"; |