- 分享
- 0
- 人气
- 0
- 主题
- 15
- 帖子
- 231
- UID
- 204441
- 积分
- 46
- 阅读权限
- 11
- 注册时间
- 2009-3-2
- 最后登录
- 2011-11-26
- 在线时间
- 191 小时
|
本帖最后由 eric1993 于 2011-6-18 07:10 PM 编辑
各位大大帮帮忙吧!!!!!
小弟正面对个大问题!!!
要怎样用 ceil() & floor() function 和 mathematic 的方式来form个formula
[1,2,3,4] = 0
[6,7,8,9] = 5
[5] = 5
用 % 的方式小弟想到头都快穿了!!!! 救命啊!
以下是小弟的 source code
#include <stdio.h>
#include <math.h>
#define GOV_TAX 0.06
#define SER_TAX 0.10
void main ()
{
int num1;
char des1[20];
double unitPrice, sum, sumtotal, gov_tax, ser_tax, discVouc, padis, lastVal, chardue, ceil_padis;
float cash;
printf("Enter Description > ");
scanf("%s", &des1);
printf("Enter Quantities > ");
scanf("%d", &num1);
printf("Enter Prices Of Descriptions > ");
scanf("%lf", &unitPrice);
printf("Enter amount of Discount Voucher > ");
fflush(stdin);
scanf("%lf", &discVouc);
printf("Enter a customer cash : ");
fflush(stdin);
scanf("%f",&cash);
sum = num1 * unitPrice;
gov_tax = sum * GOV_TAX;
ser_tax = sum * SER_TAX;
sumtotal = sum + gov_tax + ser_tax;
padis = sumtotal - discVouc;
ceil_padis = ceil(padis * 10) / 10; << 我的formula 不够完整,
lastVal = ceil_padis;
chardue = cash - lastVal;
printf("\n");
printf(" G-Core Software Development \n");
printf("\n");
printf(" Welcome to KLFC Sales Receipt System \n ");
printf("\n");
printf("\n");
printf(" RECEIPT \n");
printf("+-------------+----------+-------------+------------------+\n");
printf("| Description | Quantity | Unit Prices | Total Amount(RM) |\n");
printf("+-------------+----------+-------------+------------------+\n");
printf("| %7.13s | %d | %8.2f | %8.2f |\n", des1, num1 , unitPrice, sum);
printf("+------------------------+-------------+------------------+\n");
printf("| | Sub Total | %8.2f |\n", sum);
printf("| Goverment Tax 6%% | | %8.2f |\n", gov_tax);
printf("| Service Tax 10%% | | %8.2f |\n", ser_tax);
printf("| | +------------------+\n");
printf("| | Grand Total | %8.2f |\n", sumtotal);
printf("+========================+=============+==================+\n");
printf("| Grand Total %8.2f |\n", sumtotal);
printf("| Discount Amount %8.2f |\n", discVouc);
printf("| -------------- |\n");
printf("| Payable Amount %8.2f |\n", padis);
printf("| ============== |\n");
printf("| Adjusted Amount %8.2f|\n", lastVal); << 这边啊!
printf("+=========================================================+\n");
printf(" Total %8.2f \n", lastVal);
printf(" Cash %8.2f \n", cash);
printf(" Change Due %8.2f \n", chardue);
printf("+=========================================================+\n");
printf(" THANKYOU AND HAVE A NICE DAY \n");
printf("\n");
} |
|