3iii.cpp

来自「C/C++程序设计导论(第二版)》程序源文件」· C++ 代码 · 共 35 行

CPP
35
字号
#include <iostream.h>
// GetValueBetween()  Inputs and returns a value which
//  is between parameters min and max.
//	IN:		min -- the minimum acceptable input
//			max -- the maximum acceptable input
float GetValueBetween (float min, float max)
 {	float temp, accept;
	cout << "Enter a value between " << min << " , " << max;
	cin >> temp;
	accept = 1.0;
	while (accept > 0.0)
	 {	if (temp >= min)
			if (temp <= max) accept = 0.0;
		if (accept > 0.0)
		 {	cout << "** illegal value, enter again: ";
			cin >> temp;
		 }
	  }		
	return (temp);
 }


void CalcTable (float startperiod, float endperiod)
{
}
void main ()
{	float amount, rate, startperiod, endperiod;
	
	amount = GetValueBetween (0.0, 30000.0);
	rate = GetValueBetween (0.0, 1.0);
	startperiod = GetValueBetween (1.0, 71.0);
	endperiod = GetValueBetween (startperiod, 72.0);

	CalcTable (startperiod, endperiod);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?