FunFun - cout << "The...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> using namespace std ; int square (int x) { return x * x ; } double totalCost (int quantity, double unitPrice) { const double TAXRATE = 0.005 ; double subTotal ; subTotal = quantity * unitPrice ; return subTotal + subTotal * TAXRATE ; } char computeGrade (int score, int cutoffA, int cutoffB, int cutoffC, int cutoffD ) { if (score >= cutoffA) return 'A' ; else if (score >= cutoffB) return 'B' ; else if (score >= cutoffC) return 'C' ; else if (score >= cutoffD) return 'D' ; else return 'F' ; } void printGrade (int score) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout &lt;&lt; &quot;The grade for &quot; &lt;&lt; score &lt;&lt; &quot; is &quot; &lt;&lt; computeGrade (88, 90,80,70,60) &lt;&lt; endl ; } int main() { int squared ; squared = square(x) ; cout &lt;&lt; x &lt;&lt; &quot; squared is &quot; &lt;&lt; squared &lt;&lt; &quot;.&quot; &lt;&lt; endl ; int q = 3 ; double p = 3.45 ; cout &lt;&lt; &quot;The price of square of &quot; &lt;&lt; q &lt;&lt; &quot; items is &quot; &lt;&lt; totalCost (q, p) &lt;&lt; &quot;.&quot; &lt;&lt; endl ; cout &lt;&lt; endl &lt;&lt; endl ; cout &lt;&lt; &quot;The grade for &quot; &lt;&lt; 88 &lt;&lt; &quot; is &quot; &lt;&lt; computeGrade (88, 90,80,70,60) &lt;&lt; endl ; printGrade (77) ; return 0; }...
View Full Document

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online