⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpp02.cpp

📁 C++参考书
💻 CPP
字号:

// Coded by plusir -- Dec.29.2002.
// Standard C++ Bible -- (P232-8-2)

#include <iostream>
#include <iomanip>
using namespace std ;

const float overtime = 1.5f ;
const float taxrate = 0.15f ;
const int wkweek = 40 ;

inline int reg( int h ) { return h < wkweek ? h : wkweek ; }
inline int otime( int h ) { return h < wkweek ? 0 : h - wkweek ; }
inline float otimepay( int h, float r ) { return r * otime( h ) * overtime ; }
inline float regpay( int h, float r ) { return r * reg( h ) ; }
inline float grosspay( int h, float r ) { return otimepay( h, r ) + regpay( h, r ) ; }
inline float wholding( int h, float r ) { return grosspay( h, r ) * taxrate ; }
inline float netpay( int h, float r ) { return grosspay( h, r ) - wholding( h, r ) ; }

void setformat( void ) ;

int main()
{
	cout << "Enter hours( xx ) rate( x.xx ): " ;
	int hours ;
	float rate ;
	cin >> hours >> rate ;

	cout << "Ragular: " ;
	setformat() ;
	cout << regpay( hours, rate ) << endl ;

	cout << "Overtime: " ;
	setformat() ;
	cout << otimepay( hours, rate ) << endl ;

	cout << "Gross: " ;
	setformat() ;
	cout << grosspay( hours, rate ) << endl ;

	cout << "Witholding: " ;
	setformat() ;
	cout << wholding( hours, rate ) << endl ;

	cout << "Net Pay: " ;
	setformat() ;
	cout << netpay( hours, rate ) << endl ;

	return 0 ;
}

void setformat( void )
{
	cout
		<< setw( 10 )
		<< setiosflags( ios::fixed | ios::right )
		<< setprecision( 2 ) ;
}

⌨️ 快捷键说明

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