Professional Documents
Culture Documents
Problem Solving I Chapter 2
Problem Solving I Chapter 2
Problem Solving I Chapter 2
1
Monolithic Program
To 2
Anatomy of Monolithic C++
Program
5
Simple C++ Program
Comments
/* This program displays “Hello World” on the monitor
Date Written:……………
Written by ……………. Preprocessor
Directives
*/
#include <iostream.> //This is preprosessor directive Main function
using namespace std;
int main ( ) //this tells the starting point of your program Statements
{
cout << “Hello World” <<endl ; //print the text on monitor
return 0 ; //return to operating system
}
Return Statement
Function Body 6
Comment
Comments are used to document programs. Comments should appear in
a program to:
– Explain the purpose of the program
– Identify who wrote it
– Explain the purpose of particular statements
Any comment in your program is ignored by the compiler.
There are two ways of commenting in C++
• Block Comment - comments that can span several lines. Anything
between the symbol pair /* and the symbol pair */ is a comment. E.g
/*This is a comment that spans
three lines. Note that there is no comment
symbol of any kind on the second line.*/
• Line comment – Comments that span only a single line. Usually used
to comment a single statement. All of the text between the // and the
end of the line is a comment. E.g
y = a + b //This is a line comment 7
Preprocessor Directives
Note
• To include C++ standard library function
headers, we use the file to be included
enclosed within <> instead “”. Other file
can be included by using “”.
• It is the way of telling the preprocessor
that we are including a header file of a
standard library
11
Token
a = b + c;
Space is optional added only for readability
13
Identifiers
Identifiers allow us to name program objects such as
variable, constant, function, etc.
If we don’t have identifiers that we could use to symbolically
represent data location, we would have to know and use
data addresses to manipulate them.
C++ identifiers rule:
1. The first character must be alphabetic character or
underscore.
Caution: By custom, many of the identifiers in the system
library starts with underscore. So to avoid duplication
when you use also system library, it is recommended that
not to use identifier that start with underscore.
2. The identifier must consist only of alphabetic characters,
digits, and underscore. No other special character.
3. Keywords( or reserved words) can’t be used as identifier.
14
Identifiers…
Some important comments about identifier
1. C++ is case sensitive. Two identifiers that differ in case
are treated as different identifiers. E.g.
TEMP ,temp , Temp are three different identifiers.
2. Try to make your identifier descriptive. When the name
contains more than one word, use under score to
separate the words or use camel case notation(capitalize
the first letter of each word except the first). E.g.
sales_tax_rate or salesTaxRate
Example
Which of the following names can be used to name C++
program objects(Valid identifier)?
a a1 1a %sale pi
PI student_name_totalCost sales tax int 15
Keywords
Keywords( or reserved words) are special class of identifier
that have special meaning in C++.
• Each keyword has a predefined purpose in the
language.
• Do not use keywords as variable or constant names!!
Some of the keywords( for exhaustive list of key words use
your reference book) are listed here:
bool, break, case, char, const, continue, do, default, double,
else, extern, false, float, for, if, int, long, namespace, return,
short, signed, static, struct, switch, typedef, true, unsigned,
void, while
Note: All keywords are in lower case
16
Data Types
Data must be stored in memory in order to be manipulated
by your program. Different types of data requires different
amount of memory. It is not going to occupy the same
amount of memory to store a simple number than to store a
single letter or a large number, and they are not going to be
interpreted the same way.
Data type: set of values together with a set of operations.
The set of values constitute the domain for the type.
A type tells the compiler four things
• the amount of memory required to store the data.
• the format of the data, how the bit pattern are interpreted
• the domain or the possible values
• The operation that can be performed on the data
17
Example: Data Format
Int (32 bit) representation
01000000010010001111010111000011
28311552
float
01000000010010001111010111000011
3.14
18
Classification of C++ Data Type
The next figure shows the classification of C++ data type.
Built-in-types: defined by the system.
User-defined-types: defined by the user.
Fundamental types: built in type that can’t be broken down
void type: represent empty data value and operation
Derived Types: derived from the fundamental
Integral types: integers (numbers without a decimal)
Floating-point: decimal numbers
19
Integral Data Type
The Integral type further classified as shown below:
Integral type
long long or
signed long long
Or unsigned long long
Integer long long int or Or
signed long long int unsigned long long int
long long
short or int
unsigned short unsigned int long or unsigned long
signed short Or Or signed long Or
Or unsigned short int signed int Or unsigned long int
short int or long int or
signed short int signed long int
Integer…
C++ supports 4 integer types : short int(or short), int, long int( or long) and long
long( or long long int). Each have a signed and unsigned version. The next table
summarize the integer types
short int signed 2 -32, 768 32, 767 short (or short int)
(short)
unsigned 2 0 65,535 unsigned short
int(PC) signed 2 -32, 768 32, 767 int
unsigned 2 0 65,535 unsigned int
int(main signed 4 -2,147,483,648 2,147,483,647 int
frame) unsigned 4 0 4.294,967,295 unsigned int
long int signed 4 -2,147,483,648 2,147,483,647 long (or long int)
unsigned 4 0 4.294,967,295 unsigned long
Long long signed 8 –9, 223, 372, 036, 9, 223, 372, 036, long long (or long
int 854, 775, 808 854, 775, 807 long int)
unsigned 8 0 18, 446, 744, 073, unsigned long long
709, 551, 615
22
Character Data Type
C++ supports 2 character types : char and wchar_t. Each have a signed
and unsigned version. The next table summarize the integer types
Character
char wchar_t
25
Floating-point Data Type
floting point type
27
Variables
Variables are named memory location that have a type such as
integer or character, and consequently, a size, which is
inherited from the their type.
The content of the variable may change through the execution
of the program.
28
Variable Declaration
In C++, all the variables that a program is going to use must be
declared prior to use.
Declaration of a variable serves two purposes:
1. It associates a type and an identifier (or name) with the
variable. The type allows the compiler to interpret
statements correctly. For example in the CPU the instruction
to add two integer values together is different from the
instruction to add two floating-point values together. Hence
the compiler must know the type of the variables so it can
generate the correct add instruction.
2. It allows the compiler to decide how much storage space to
allocate for storage of the value associated with the identifier
and to assign an address for each variable which can be used
in code generation.
29
Variable Declaration…
A variable declaration has the form:
type identifier1, identifier2, …;
type specifies the type of the variables being declared. The
identifier1, identifier2, … is a list of the identifiers of the
variables being declared, separated by commas.
Example
char code;
unsigned int i;
double payRate, price;
30
Variable Initialization
Variables may be initialized at the time of declaration by assigning a value
to them. Initialization gives initial value to variables. There are two ways
of initializing.
type identifier1 = value1, identifier2 = value2; …
type identifier1 (value1) , identifier2 (value2)…;
type identifier1 {value1} , identifier2 {value2}…;
Example:
int i, j, count(0);
float sum = 0.0, product{10};
char ch = ‘a';
bool passed_exam = false;
i, j have no initial value specified, so the program should make no
assumption about their contents.
31
Example-Variable(Real Code)
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int a, b=0; // declaring variables:
int result;
a = 5;
b = 2;
a = a + 1;
result = a - b;
cout << result<<endl; // print out the result:
system(“pause”);
return 0; // terminate the program:
}
32
Automatic Type Deduction
The auto keyword can be used to let the compiler decide the
data type itself.
The auto keyword specifies that the type of the variable that is
begin declared will automatically be deduced from its initialize
Example
auto i=4; //i is an int
auto x=3.4; //x is double
auto s=sqrt(x);//s is double as the sqrt function returns double
33
Constants
Constants are data values that can’t be changed during
program execution.
Like variables, constants have a type.
C++ has three kinds of constants: literal, defined, and
memory constants.
34
Literal Constants
Literal constants are unnamed constants used to express particular
values within the source code of a program.
Literal constants can be divided in Integer Numerals, Floating-Point
Numerals, Characters, Strings and Boolean Values
1. Integer Literals
They are numerical constants that identify integer decimal values
If the number is with in the range of int, by default its type will be signed
int, otherwise its type will be long int or long long int. You can override
the default value by specifying unsigned(u or U) , long(l or L) and long
long(ll or LL)
12 //its type is int
5123451234567895664545 //its type is long
-31L //its type is long
765432UL //its type is unsigned long
23ULL //its type is unsigned long long
35
Literal…
C++ also allows the use of literal constants of binary numbers(base 2), octal
numbers (base 8) and
hexadecimal numbers (base 16). If we want to express an octal number
we have to precede it with a 0 (zero character). And in order to express
a hexadecimal number we have to precede it with the characters 0x
(zero, x). Example
75 // decimal
0b101 //binary
0113 // octal
0x4b // hexadecimal
2. Floating Point Literals
They express numbers with decimals and/or exponents. The default type is
double. You can override by specifying float(f or F) and long double(l or L).
Example
2.0 //double
6.02e-23 //double
3.1416f //float 36
-6.02e145L //long double
Literal…
3. Character literal
A character literal are enclosed between two single quotes ( apostrophe
). When the character to be represented does not have any graphics
associated with it: that is when it can’t be printed or entered from the
key board, escape character(backslash \) is used.
Example
‘A’ //the character a
‘7’ //the character 7
‘ ‘ //the character space
Some escape sequence for special character
Null character ‘\0’ New line ‘\n’
alert(bell) ‘\a’ form feed ‘\f’
Back space ‘\b’ carriage return ‘\r’
Horizontal tab ‘\t’ single quote ‘\’’
Vertical tab ‘\v’ backslash ‘\\’
37
Literal…
4. String literal
A string literal is a sequence of zero or more characters
enclosed in double quotes. Example
“” //null string
“h” // a string h
“Hello world\n” // Hello world
“\’’Good\” Morning” // “Good” Morning
5. Boolean Literal
The bool type has two predefined literals associated with it:
true and false .
38
Defined Constants
Another way to designate a constant is to use the
preprocessor command. Its general format is
39
Memory Constants
C++ provides a capability to define a named constant. We
use the C++ type qualifier const before the definition. The
general syntax is
const type identifier=value;
Note: Const variables must be assigned a value when
declared, and then that value cannot be changed.
For example:
const double PI = 3.14159;
const char NEWLINE = ‘\n’;
const int MYCONST; //invalid!
As a good programming style use upper case identifier for
defined and memory constant.
40
Example - Constant
// Using literal constant
#include <iostream>
using namespace std;
int main ()
{
double radius, circumf;
cout << “Please enter radius: “;
cin >> radius;
circumf = 2 * 3.14159 * radius;
cout << ‘\n’ << “The circumference is: “ << circumf<<endl;
system(“pause”);
return 0;
} 41
Example - Constant
// defined constants: calculate circumference
#include <iostream.>
using namespace std;
#define PI 3.14159
#define NEWLINE '\n'
int main ()
{
double radius, circumf;
cout << “Please enter radius: “;
cin >> radius;
circumf = 2 * PI * radius;
cout << NEWLINE << “The circumference is: “ << circumf<<endl;
system(“pause”);
return 0;
42
}
Example - Constant
// memory constants: calculate circumference
#include <iostream>
using namespace std;
const double PI = 3.14159;
const char NEWLINE = ‘\n’;
int main ()
{
double radius, circumf;
cout << “Please enter radius: “;
cin >> radius;
circumf = 2 * PI * radius;
cout << NEWLINE << “The circumference is: “ << circumf<< NEWLINE;
system(“pause”);
return 0;
43
}
C++ Operators
An operator is a language specific syntactical token that
requires an action to be taken.
C++ provides several operators for composing expression:
• Arithmetic
• Increment and decrement
• Relational and equality
• Logical
• Assignment
• Compound Assignment
• Bit-wise Logical
• Conditional
• Comma
• Explicit Type Casting
• Sizeof 44
Arithmetic Operators
45
Arithmetic…
• Except for remainder (%), all other arithmetic operators can accept a
mix of integer and real operands. For the modulo operator(%) both
operands must be integral.
• AS a general rule, if both operands are of the same type then the
result will be also of that type.
• Thus, when both operands of the division operator (/) are integers
then the division is performed as an integer division and not the
normal division we are used to. Integer division always results in an
integer.For example:
9 / 2 // gives 4, not 4.5!
-9 / 2 // gives -4, not -4.5!
• It is possible for the outcome of an arithmetic operation to be too
large for storing in a designated variable. This situation is called an
overflow. The outcome of an overflow is machine-dependent and
therefore undefined.
46
Relational Operators
C++ provides seven relational operators for comparing numeric
quantities. These are summarized in Table below. Except the
spaceship operator the result of a relational operation is a Boolean
value that can only be true(1) or false (0), according to its Boolean
result.
Operator Name Example
== Equality 3 == 3 //Gives true
!= Inequality 3 !=3 //Gives false
< Less Than 3<3 //Gives false
<= Less Than or Equal 3.5 <= 3 //Gives false
> Greater Than 3.5 > 3.5 //Gives false
>= Greater Than 3.5 >= 3.5 //Gives true
<=> The spaceship a<=>b gives value less than 0 if a< b
gives value 0 if a ==b
gives value greater than 0 if a>b 47
Relational …
48
Logical Operator
C++ provides three logical operators for combining logical
expression. These are summarized in the table below. Like the
relational operators, logical operators evaluate to 1 or 0.
Operator Type Name Example
! unary Logical Negation !(3>5) //Gives true
&& binary Logical And 3>5 && 2 < 4 //Gives false
|| binary Logical Or 3<5 || 2 > 4 //Gives true
Logical Negation
If its operand is true or non-zero it produces false, and if it is false or zero it
produces true.
Logical And
Produces false if one or both of its operands evaluate to false or zero. Otherwise, it
produces true.
Logical Or
Produces false if both of its operands evaluate to false or zero. Otherwise, it 49
produces 1.
Logical…
Note
• we talk of zero and nonzero operands (not zero and 1). In general, any
nonzero value can be used to represent the logical true, whereas only
zero represents the logical false. The following are, therefore, all valid
logical expressions:
!20 // gives 0 10 || 5.5 // gives 1
10 && 5 // gives 1 10 && 0 // gives 0
• In evaluating logical && expression, if the left part is evaluated to
false, there is no need to evaluate the second expression. A similar
thing happens with || expressions. If the first of two expressions
joined with the || operator is true, then you know the entire
expression is true, no matter whether the second expression is true or
false. The C++ language operates in a “short circuit mode”, i.e., if the
truth value of the whole expression can be determined by evaluating
the left expression of && or ||, C++ does not bother to evaluate the
right expression. But this may not be true for other languages.
E.g 1 > 2 && 7 < 3 // the expression 7 < 3 will not be evaluated
1 < 7 || 5 < 4 //the expression 5 < 4 will not be evaluated 50
Assignment Operator
The assignment operator(=) is used for storing a value at some
memory location (typically denoted by a variable).
The part at the left of the assignment operator (=) is
known as the lvalue (left value) and the right one as the rvalue (right
value).
The lvalue has to be a variable whereas the rvalue can be either a
constant, a variable, the result of an operation or any combination of
these.
In an assignment statement, first the expression on the right-hand side of
the equal sign is evaluated
and then the variable on the left-hand side of the equal sign is set equal to
this value.
SYNTAX
Variable = Expression;
EXAMPLES
distance = rate * time;
a=5 //assign 5 to the variable a
5=a // invalid assignment left side should be an lvalue
51
Increment/Decrement Operators
The auto increment (++) and auto decrement (--) operators provide a
convenient way of, respectively, adding and subtracting 1 from a numeric
variable. These are summarized in the table below. The examples assume
the following variable definition:
int k = 5;
Operator Name Example
++ Prefix increment Y = ++k + 3 //k will be 6 and y will be 9
++ Postfix increment Y = k++ + 3 //k will be 6 and y will be 8
-- Prefix decrement Y = --k + 3 //k will be 4 and y will be 7
-- Postfix decrement Y = k-- + 3 //k will be 4 and y will be 8
i++, ++i are identical to i= I + 1
i--, --i are identical to i= I - 1
Both operators can be used in prefix and postfix form. The difference is
significant. When used in prefix form, the operator is first applied and the
outcome is then used in the expression. When used in
the postfix form, the expression is evaluated first and then the operator
52
Bitwise Operators
C++ defines several bitwise operators that can be applied to the
integer types:long long, long, int, short, char. These operators act
upon the individual bits of their operands.
1. Bitwise NEGATION(~) is a unary operator which reverses the
bits in its operands.
2. Bitwise AND(&) compares the corresponding bits of its
operands and produces a 1 when both bits are 1, and 0
otherwise.
3. Bitwise OR (|) compares the corresponding bits of its
operands and produces a 0 when both bits are 0, and
1otherwise.
4. Bitwise EXCLUSIVE OR(^ ) compares the corresponding bits of
its operands and produces a 0 when both bits are 1 or both
bits are 0, and 1 otherwise 0.
53
Bitwise…
5. The bitwise LEFT SHIFT (<<) moves the data left a specified number
of bits. Any bits that are shifted out the left side disappear. New bits
coming in from the right are zeros.
Shifting left by n places is the same as multiplying by 2n.
6. The bitwise RIGHT SHIFT (>>) does the same thing in the other
direction. When a variable is shifted to the right, C++ needs to fill the
space on the left side with something. For signed variables, C++
uses the value of the sign bit. For unsigned variables, C++ uses zero
These are summarized in Table below. In the table below, The
examples assume the following variable definition:
54
Bitwise…
These are summarized in Table below. In the table below, The examples assume
the following variable definition:
int cl = 0x45; //00000000000000000000000001000101 (69)
int c2 = 0x71; //00000000000000000000000001110001 (113)
55
Exercise
How can we set the bit at bit position 4 of unsigned int variable n?
How can we unset the bit at bit position 4 of unsigned int variable
n?
How can we toggle the bit at bit position 4 of unsigned int variable
n?
How can we test if the bit at bit position 4 of unsigned int variable
is off?
56
Compound Assignment
57
Conditional operator
The conditional operator is a ternary operator the takes three
operand. Its general format is:
condExpr? expr1 : expr2
Where condexpr is any conditional expression, and expr1 and
expr2 are valid expression.
First the conditional expression is evaluated, which is treated as a
logical condition. If the result is nonzero then expr1 is evaluated
and its value is the final result. Otherwise, expr2 is evaluated and
its value is the final result.
Example 1:
int m = 1, n = 2;
int min = (m < n ? m : n); // min receives 1
int min = (m < n ? m++ : n++); //result?
58
Comma Operator
63
Operator Precedence
Precedence Operator Description Associativity
1 () Function call Left to right
[] Array reference
-> Indirection reference
:: Scope access
. Direct reference
2 ++ - - Unary Postfix Left-to right
3 ++ - - ~ ! sizeof Unary Prefix Right-to left
+ - Unary Sign
4 (type) , static_cast < type > type casting Right-to left
6 */% multiplicative Left-to right
7 + - additive Left-to right
8 << >> shift Left-to right
9 < > <= >= relational Left-to right
10 == != equality Left-to right 64
Operator Precedence
65
Example
66
Type of Expression
3. Float expressions
Float expressions are those which, after all conversions,
produce floating – point results. Examples:
x * y / 10.0 //double
5 + float(10) //float
where x and y are integer variable
4. Relational expressions
Relational expressions yield results of type bool which
takes a value true(1) or false(0). Examples:
x <= y
a+b == c+d
68
Type of Expression
5. Logical expressions
Logical expressions combine two or more relational
expressions and produce bool type results. Examples:
a>b && x==10
x==10 || y==5
6. Bitwise expressions
An expression that involves one or more bitwise operator
and produce an integral value. Examples:
!a << 4
a&b
69
Side Effects
71
Mixed…
73
Statements
75
Input and Output
76
Stream, Data Source and
Destination
A stream is an abstract representation of an input
or output
A stream is an abstract channel or conduit where
data are passed to data destination from data
source.
Input(data source): A stream that flows from an
input device ( i.e.: keyboard, disk drive, network
connection) to main memory(or your program)
Output(data destination): A stream that flows from
main memory(or your program) to an output
device ( i.e.: screen, printer, disk drive, network 77
connection)
Data Source
data source:
our program
data destination:
78
Standard Streams
82
Writing…
Some manipulator to use
Manipulator Scope Use
endl One time New line
fixed permanent Displays a floating number in fixed
format.
scientfic permanent Display in scientific format
showpoint permanent Shows decimal in floating point values
cout.setf(ios::left) permanent Right justify text in width area
cout.setf(ios::right) permanent Right justify text in width area
setw(…) One time Set width of output fields
setprecision(…) permanent Sets number of decimal for floating point
setfill(…) permanent Specifies fill character.
83
Writing…
Additional manipulators in the iomanip header file
Manipulator Scope Use
setw(…) One time Set width of output fields
setfill(…) permanent Specifies fill character.
right permanent Sets right alignment
left permanent Sets left alignment
fixed Permanent Display floating numbers in scientific format
scientific Permanent Display floating numbers in scientific format
setprecision(…) permanent Sets number of decimal for floating point
oct,hex, dec Permanent number base to be used in displaying integers
84
Example
//Example: using manipulator
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int age = 55;
weight = 89.3456;
cout<<fixed<< setprecision(2);
cout <<left<< setw(20) <<“Name” << ‘\t’ <<“setw(3) <<“Age” << ‘\t’ << setw(10) << “Weight”<<
endl; // Heading
cout << setw(20) << “Kebede Samson” << “\t” << setw(3) << age << ‘\t’<< right << setw(10) <<
weight << endl ;
age = 25; weight = 58.7895;
cout << left<< setw(20) << “Hirut Lemma” << “\t” << setw(3) << age << ‘\t’ << right << setw(10)
<< weight << endl;
age = 45; weight = 75.4378;
cout <<left << setfill(‘*’) << setw(20) << “Dawit Moges” << “\t” << setw(3) << age << ‘\t’ << right
<< setw(10) << setprecision(3)<< weight << endl;
return 0;
}
85
Reading data from Standard Input
The extraction operator(>>) can be used with cin to read formatted
data(the standard data types) from the standard input(keyboard). The
general syntax is:
cin >>var1 >>var2,…;
Where var1, var2, … are variables of any standard types.
When a program reaches a cin statement, it waits for input to be entered
from the keyboard.
The input to cin is buffered. That means the data you type don’t get sent
to the program until you press Enter.
When reading data into a char variable
>> skips leading whitespace, finds and stores only the next character
Reading stops after a single character
To read data into an int or double variable
>> skips leading whitespace, reads + or - sign (if any), reads the
digits (including decimal for float type)
Reading stops on whitespace or non-digit character
86
Reading…
Example:
int n;
char ch;
float f;
88
Class Exercise
1. A modern shopkeeper wanted a program that calculates the selling
price of an item given its cost. He expected to gain 15% of the cost as
a profit. The shopkeeper expected you to write this program.
– Identify the input.
– Identify the output.
– Identify the process to change the input to the output (the solution).
– Write the algorithm.
– Translate its algorithm to a C++ code.
– The profit factor is to be literal constant.
2. Modify the above program so that the profit factor is to be declared as
defined constant.
3. Modify the above program so that the profit factor is to be declared as
memory constant.
89
Class Exercise...
4. Write a program that prompts a user to enter the number of second
elapsed for an event and converts this to m hours, n minute and p
seconds. For example if the user enter 7840, the program display
2:10:40.
5. Write a program that prompts a user for an integer value in the range
0 to 32767 and then prints the individual digits of the number on a
line with four spaces between the digits. The first line is to start with
the left most digit and prints all five digits; the second line is to start
with the second digit from the left and print four digits, and so forth.
For example if the user enters 1234, the output looks like
0 1 2 3 4
1 2 3 4
2 3 4
3 4
4
90
Class Exercise...
6. Write a program that asks for a person’s height and weight then
computes the body mass index (BMI) to tell whether the person is
underweight, balanced or overweight. BMI is computed as weight in
kilogram divided by square of height in meters (BMI = weight /
(height)2). An underweight person’s BMI is assumed to be less than 20,
while an overweight persons’ BMI is above 25. A BMI between 20 and
25 is assumed to be a balanced person.
7. Write a program that exchange two integer variables without using a
temporary variable.
91
Assignment
Write a program to create a customer’s bill for a company. The company sells only
five different products: TV, VCR, Remote Controller, CD player and Tape Recorder.
The unit prices are $400.00, $220.00, $300.00, and $150.00 respectively. The tax
rate is 8.25 % of the sale. The program must prompt and read the quantity sold for
each product and produce an output shown below (you may need to use
manipulator functions, IOS class).
QTY DESCRIPTION UNIT TOTAL
PRICE PRICE
_ _____________ _____ _________
XX TV 400.00 XXXX.XX
XX VCR 220.00 XXXX.XX
XX REMOTE CTRLR 35.20 XXXX.XX
XX CD PLAYER 300.00 XXXX.XX
XX TAPE RECORDER 150.00 XXXX.XX
__________
SUBTOTAL XXXX.XX
TAX XXX.XX
TOTAL XXXX.XX
92