he service charge is $7.00. It costs $0.45 per page for the first ten pages and $0.10 for each additional page. T
Write a function that will find the cost to send an international fax. The service charge is $7.00. It costs $0.45 per page for the first ten pages and $0.10 for each additional page. Take as parameter the number of pages to be faxed, and calculate the total amount due. The total amount due is returned to the main program. (Only a function is required here)
Source code in C++
#include<iostream> //define the header
using namespace std;
int main() //define the main
{
float pages, Tcost; //declare the float variables
cout<<"please enter number of pages"<<endl //display the message to enter the number of pages
cin>>pages; //Reading the pages
if(pages<=10) //validating the conditions
{
Tcost=3+pages*0.45; //conditions
}
else //else block for alternative
{
if(10<pages<=100) //again checking the condition
Tcost=3+10*0.45+(pages-10)*0.1;
else //else block for alternative
Tcost=1+0.45*10+(pages-10)*0.10; //applying the condition
}
cout<<"Total cost is: "<<Tcost; //display message of total cost
return 0;
}
Step by step
Solved in 2 steps with 1 images