KAIHATSUGIKEN GROUP

C++ PROGRAMMING LANGUAGE



********************************************************************************
4 簡単な演算処理
*********
+ 加算 total=cost + tax;
- 減算 change=payment -total;
* 乗算 tax=cast*tax_rate;
/ 除算 average=total/count;
********************************************************************************
#include <iostram.h>
void main(void)
{
cout << "5" + 7 = " << 5 + 7 << endl;//文字列の後に計算結果を表示
cout << "12 - 7 = " << 12 - 7 << endl;
cout << "1,2345 * 2 = " << 1.2345 * 2 << endl;
cout << " 15 / 3 = " << 15 / 3 << endl;
}
********
c:\showmath <enter>
5 + 7 = 12
12 - 7 = 5
1.2345 * 2 = 2.469
15 / 3 = 5
********************************************************************************
変数同士を計算することもできます。
その計算結果をさらに変数に格納
***********************************
#include <iostream.h>
void main(void)
{
	float cost = 15.00;		//float型のそれぞれの変数に値を代入
	float sales_tax = 0.06;
	float amount _paid = 20.00;
	float tax, change, total;

	tax = cost * sales_tax;	 	//cost とsales_taxの計算結果をtaxに代入
	total = cost + tax;		//cost とtaxの計算結果をtotalに代入
	change = amount_paid - total;	//amount_paid とtotalの結果をchangeに代入

	cout << "Item Cost: $" << cost << "\tTax: $" << tax <<
		"\tTotal: $" << total << endl;	//\tは 水平タブのこと

	cout << "Customer change: $" << change << endl;
}
********
c:\mathvars <enter>
Item Cost: &15.5	Tax:0.93 Total: $16.43
Customerchange: $3.57
********************************************************************************
#include <iostream.h>
void main(void)							//ここから始まる
{
	float cost = 15.00;				// costに15.00を代入
	float sales_tax = 0.06;				//sales_taxに0.06を代入
	float amount _paid = 20.00;			//amountに20.00を代入
	float tax, change, total;		//float型のtax,change,totalを準備

	tax = cost * sales_tax;		//costの値掛けるsales_taxの値をtaxに代入
	total = cost + tax;		//costの値足すtaxの値をtotalに代入
	change = amount_paid - total;	//amount_paid引くtotalの値をchangeに代入

	cout << "Item Cost: $" << cost << "\tTax: $" << tax <<//"\t"は水平タブ
		"\tTotal: $" << total << endl;		//endl;で改行

	cout << "Customer change: $" << change << endl;	
							//coutでそれぞれを出力
}
********
c:\mathvars <enter>
Item Cost: &15.5	Tax:0.93 Total: $16.43
Customerchange: $3.57
********************************************************************************