Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

way selection : Suppose that the cost of sending an international fax is calcula

ID: 3732967 • Letter: W

Question

way selection : Suppose that the cost of sending an international fax is calculated as follows: the service charge is $3.00, $.2 per page for the first 10 pages, and $.10 for each additional page. Design an algorithm that asks the user to enter the number of pages to be faxed to calculate the amount due Enter the number of pages Is the pages>10? False Print charge-0.1*(pages- 10)+0.2*10 Print charge-0.2*pages Total charge-Print charge + service charge Print out the number of pages and the total charge #include "stdafx.h" #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) //1) delcare variables //2) prompt the input of pages //3) calculation //calculate print charge //claculate totalcharge //4) print out the number of pages and total charge system("pause"); return e

Explanation / Answer

#include "stdafx.h"
#include<iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

// 1) declare variables

int pages;

float printcharge, totalcharge, servicecharge = 3;

// 2) Prompt the input of pages

cout << "Enter the number of pages: ";

cin >> pages;

// 3) calculation

// Calculate print charge

if(pages > 10)

{

printcharge = 0.1*(pages-10) + 0.2*10;

}

else

{

printcharge = 0.2*pages;

}

// Calculate totalcharge

totalcharge = printcharge + servicecharge;

// 4) print out the number of pages and total charge

cout << "Number of pages: " << pages << endl;

cout << "Charge for them: " << totalcharge;

system("pause");
return 0;

}

/* SAMPLE OUTPUT

Enter the number of pages: 15

Number of pages: 15

Charge for them: 5.5  

Enter the number of pages: 8

Number of pages: 8

Charge for them: 4.6

*/