学习札记习题2.4

学习笔记习题2.4/*?exprice 2.4*/#includestdio.hint main(){??? //const float per_day_work 8.0f /

学习笔记习题2.4

/*
?exprice 2.4
*/
#include<stdio.h>
int main(){

??? //const float per_day_work = 8.0f ;//每天工作8小时
??? const int? per_dollor_cent = 100 ;//一美金=100美分

??? float sallory = 0.0f ;//接收用户输入的薪水
??? float workh = 0.0f ;//接收用户输入的工作时数

??? float cent = 0.0f ;//定义总的美分数
//??? float dollor = 0.0f ;//定义总的美元数
??? float cent_h = 0.0f ;//每小时的美分数
//??? int dollor_h = 0 ;//每小时的美元数
??? int meiyuan_h = 0 ;//每小时收入美元
??? int meifen_h = 0 ;
???
???
??? printf("input your sallary in week :\n");
??? scanf("%f" , &sallory);
??? printf("input your work hours in h :\n");
??? scanf("%f",&workh);
???
??? cent = sallory * (float) per_dollor_cent;
??? if(workh == 0.0f){
??? ??? cent_h = 0 ;
??? }else{
??? ??? cent_h = cent / workh ;
??? }
???
??? meiyuan_h = (int) (cent_h / (float)per_dollor_cent );
??? meifen_h = (int) cent_h %per_dollor_cent ;

??? printf(" your average hourly pay rate is %d dollars and %d cents" , meiyuan_h ,meifen_h);
??? return 0 ;
???


}