Hi guys I’m trying to give a returned value to another function to perform a task but its not working
I’ve googled for a long time and i still can’t find a solution
So if anybody can help me out🥲
MODIFIED VERSION :
#include <iostream>
using namespace std;
string CustomerDetails(string name){ // this function is not mandatary you can just print from main
cout<<"\n***** Welcome "<<name<<" *"<<endl;
cout<<endl;
return name;
}
int unitConsumed(double previous,double current){
double unit;
unit = current - previous;
return unit;
}
string customerType(double p, double c){ // taking parameters bcoz you can't say meter reading directly
string domestic = "Domestic", industrial = "Industrial", commercial = "Commercial";
if (unitConsumed(p,c) < 100)
return domestic;
else if (unitConsumed(p,c) > 100 && unitConsumed(p,c) <= 200)
return industrial;
else // place 'else' instead of 'else if' then complier won't warn you
return commercial;
}
int main() {
string name;
cout <<"Please Enter Your Name: ";
getline(cin,name); //
CustomerDetails(name);
double currentMeter, PreviousMeter;
cout <<"\n\nEnter Previous Meter Reading (kwh): ";
cin>>PreviousMeter;
cout<<"\nEnter Current Meter (kwh): ";
cin>>currentMeter;
unitConsumed(PreviousMeter, currentMeter);
cout<<endl;
cout<<unitConsumed(PreviousMeter, currentMeter);
cout<<endl;
cout <<customerType(PreviousMeter, currentMeter);
return 0;
}